Traffic flow prediction method and device, electronic equipment and storage medium

By using large language models to process and predict traffic flow data, the problem of insufficient performance of existing traffic flow prediction models is solved, and more efficient traffic flow prediction is achieved.

CN119992820AActive Publication Date: 2025-05-13QINGDAO HISENSE TRANS TECH

Patent Information

Application Number
CN202411976988.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-05-13
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

The existing traffic flow prediction model based on statistics, machine learning and deep learning has the problem of poor promotion and widening performance.

Method used

The traffic flow prediction is carried out by using a large language model, and the historical traffic flow sequence is obtained for normalization and quantization, the quantized data is input into the large language model for prediction, and the final predicted traffic data is obtained through inverse quantization and anti-standardization.

Benefits of technology

The performance of the traffic flow prediction model is improved, and the problems of high cost and poor scalability of the existing models are avoided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119992820A_ABST
    Figure CN119992820A_ABST
Patent Text Reader

Abstract

The invention discloses a traffic flow prediction method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring a traffic flow sequence of a target intersection in a first historical time period; standardizing each first traffic flow data of the traffic flow sequence, and determining corresponding second traffic flow data; quantizing each second traffic flow data in a preset historical window, and determining each corresponding first quantized character; inputting each first quantized character into the large language model, and determining a second quantized character of at least one sub-time period in the prediction window based on the large language model; and finally, carrying out inverse quantization and inverse standardization on the second quantization character, and determining corresponding predicted traffic data. And traffic flow prediction based on the large language model is realized. The problems of high popularization and generalization cost and poor expandability of traffic flow prediction based on statistics, machine learning and deep learning prediction models in the prior art are avoided. And the popularization and generalization performance of the traffic flow prediction model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of traffic forecasting and analysis, and in particular to a traffic flow forecasting method, device, electronic device and storage medium. Background Art

[0002] The current intelligent transportation system driven by big data and artificial intelligence technology is developing from perception intelligence to predictive and warning intelligence. Traffic managers can analyze the situation based on the prediction results and make accurate decisions. Therefore, accurate and efficient traffic flow prediction has a great impact on reasonable traffic decision-making, command and dispatch, safety control, etc.

[0003] At present, the mainstream prediction models in the transportation industry include statistical prediction, machine learning prediction and deep learning prediction models. Statistical prediction models are simple and easy to use, but they are not effective in describing complex traffic patterns. Machine learning prediction models are limited by artificial feature dependency modeling, resulting in poor prediction performance. End-to-end prediction models based on deep learning can improve feature dependency and prediction effect problems, but deep learning prediction models are strongly dependent on scene data. Due to the complexity and irregularity of traffic flow prediction scenes, the accuracy of traffic flow prediction by deep learning prediction models cannot be guaranteed. Existing traffic flow prediction based on statistics, machine learning and deep learning prediction models has the problem of poor generalization performance. Summary of the invention

[0004] The present application provides a traffic flow prediction method, device, electronic device and storage medium to solve the problem of poor generalization performance of existing traffic flow prediction based on statistics, machine learning and deep learning prediction models.

[0005] In a first aspect, the present application provides a traffic flow prediction method, the method comprising:

[0006] Acquire a traffic flow sequence in a first historical time period of the target intersection; wherein the traffic flow sequence includes first traffic flow data in each sub-time period arranged in chronological order; standardize each first traffic flow data to determine corresponding second traffic flow data;

[0007] Quantifying each second traffic flow data in a preset historical window to determine each corresponding first quantized character; wherein the first quantized character is a character that can be recognized by the large language model;

[0008] The first quantized characters are input into the large language model, and a second quantized character of at least one sub-time period within a prediction window is determined based on the large language model; the second quantized characters are dequantized and denormalized to determine corresponding predicted traffic data.

[0009] The above technical solution has the following advantages or beneficial effects:

[0010] In order to solve the problem of poor accuracy of traffic flow prediction in the prior art, considering the advantages of the large language model, this application proposes a traffic flow prediction method based on a large language model. First, obtain the traffic flow sequence in the first historical time period of the target intersection; standardize each first traffic flow data of the traffic flow sequence to determine the corresponding second traffic flow data; then quantize each second traffic flow data in the preset historical window to determine the corresponding first quantized characters; then input each first quantized character into the large language model, and determine the second quantized character of at least one sub-time period in the prediction window based on the large language model; finally, dequantize and destandardize the second quantized character to determine the corresponding predicted traffic data. Thus, traffic flow prediction based on a large language model is realized. The problems of high generalization cost and poor scalability of existing traffic flow prediction based on statistics, machine learning and deep learning prediction models are avoided. The generalization performance of the traffic flow prediction model is improved.

[0011] In an optional implementation manner, the step of normalizing each first traffic flow data to obtain the corresponding second traffic flow data includes:

[0012] Determine the average value and standard deviation of each of the first traffic flow data; for each of the first traffic flow data, determine the difference between the first traffic flow data and the average value, and determine the ratio of the difference to the standard deviation as the standardized second traffic flow data corresponding to the first traffic flow data.

[0013] The above technical solution has the following advantages or beneficial effects:

[0014] In the present application, when standardizing each first traffic flow data, the average value and standard deviation of each first traffic flow data are first determined, and then for each first traffic flow data, the difference between the first traffic flow data and the average value is calculated, and then the ratio of the difference to the standard deviation is calculated, and the ratio is determined as the standardized second traffic flow data corresponding to the first traffic flow data. This improves the accuracy of traffic flow data standardization.

[0015] In an optional implementation, quantizing each second traffic flow data in a preset historical window to determine each corresponding first quantization character includes:

[0016] Determine the number of segmentation intervals according to the first number of each second traffic flow data in the preset historical window and the second number of the predicted traffic flow data preset in the prediction window; determine each segmentation interval and the quantization character corresponding to each segmentation interval according to the number of segmentation intervals and the percentile function of the standard normal distribution;

[0017] For each of the second traffic flow data, determine the first segmentation interval to which the second traffic flow data belongs; and determine the quantization character corresponding to the first segmentation interval as the first quantization character corresponding to the second traffic flow data.

[0018] The above technical solution has the following advantages or beneficial effects:

[0019] First, the first number of each second traffic flow data in the preset historical window is obtained. For example, the preset historical window is 40 minutes in history, and the sub-time period is 5 minutes, then the first number of each second traffic flow data in the preset historical window is 40 / 5=8. Then the second number of the preset predicted traffic flow data in the prediction window is obtained. For example, it is pre-specified that the traffic flow every 5 minutes in the next 10 minutes is predicted based on the historical data of 40 minutes, so the second number of the preset predicted traffic flow data in the prediction window is determined to be 10 / 5=2. The number of segmentation intervals is determined according to the first number and the second number. Optionally, the sum of the first number and the second number can be determined as the number of segmentation intervals. According to the number of segmentation intervals and the percentile function of the standard normal distribution, each segmentation interval and the quantization character corresponding to each segmentation interval are determined. Among them, according to the number of segmentation intervals and the percentile function of the standard normal distribution, the number of segmentation intervals minus 1 boundary value can be determined, and these boundary values ​​are arranged from small to large to obtain each segmentation interval. Among them, the smallest segmentation interval is from negative infinity to the smallest boundary value, and the largest segmentation interval is from the largest boundary value to positive infinity. For example, the quantization characters corresponding to each segment interval are 1 to 10 in order from small to large. That is, the quantization character corresponding to the smallest segment interval is 1, and the quantization character corresponding to the largest segment interval is 10. It should be noted that if the number of segment intervals is more than 10, the quantization character corresponding to the largest segment interval is a value greater than 10. For each second traffic flow data, the first segment interval to which the second traffic flow data belongs is first determined; then the quantization character corresponding to the first segment interval is determined as the first quantization character corresponding to the second traffic flow data. This improves the accuracy of the quantization of the traffic flow data.

[0020] In an optional implementation, the process of dequantizing the second quantized character includes:

[0021] Determine a second segmentation interval corresponding to the second quantized character; determine two boundary values ​​of the second segmentation interval; and determine an average value of the two boundary values ​​as the value of the second quantized character after dequantization.

[0022] The above technical solution has the following advantages or beneficial effects:

[0023] In the present application, each first quantized character is input into a large language model, and after the second quantized character of at least one sub-time period in the prediction window is determined based on the large language model, for at least one second quantized character, the second segmentation interval corresponding to the second quantized character is first determined; then the two boundary values ​​of the second segmentation interval are determined, and then the average value of the two boundary values ​​is determined, and the average value is determined as the value of the second quantized character after dequantization. Thereby improving the accuracy of the dequantization of the second quantized character. It should be noted that for the smallest segmentation interval, that is, the segmentation interval from negative infinity to the smallest boundary value, the smallest boundary value can be used as the average value corresponding to the smallest segmentation interval; for the largest segmentation interval, that is, the segmentation interval from the maximum boundary value to positive infinity, the maximum boundary value can be used as the average value corresponding to the largest segmentation interval.

[0024] In an optional implementation manner, performing de-normalization on the de-quantized value of the second quantized character to determine the corresponding predicted traffic data includes:

[0025] Determine the product of the inverse quantized value and the standard deviation; and determine the sum of the product and the average value as the corresponding predicted flow data.

[0026] The above technical solution has the following advantages or beneficial effects:

[0027] In the present application, for each second quantized character, after determining the inverse quantized value corresponding to the second quantized character, the product of the inverse quantized value and the standard deviation is calculated; then the sum of the product and the average value is determined as the predicted traffic data corresponding to the inverse quantized value. Thus, traffic flow prediction based on a large language model is achieved. It should be noted that the standard deviation and the average value are the average value and standard deviation of each determined first traffic flow data.

[0028] In an optional implementation, the training process of the large language model includes:

[0029] Obtaining a sample traffic flow sequence corresponding to each intersection in the second historical time period, and determining a training sample set according to each sample traffic flow sequence; wherein the sample traffic flow sequence includes first sample traffic flow data in each sub-time period arranged in chronological order;

[0030] For each sample traffic flow sequence in the training sample set, each first sample traffic flow data in the sample traffic flow sequence is standardized to determine the corresponding second sample traffic flow data; each second traffic flow data in a preset historical window and a prediction window is quantized to determine the corresponding first sample quantized characters; wherein the first sample quantized characters are characters that can be recognized by the large language model;

[0031] Input each first sample quantized character in the preset historical window into the large language model to be trained, and extract the semantic vector of each first sample quantized character based on the generative pre-training model and the low-rank adaptation network in the large language model; determine the predicted quantized character of at least one sub-time period in the prediction window based on the semantic vector; determine the loss value according to the predicted quantized character and the first sample quantized character of at least one sub-time period in the prediction window; and train the large language model according to the loss value.

[0032] The above technical solution has the following advantages or beneficial effects:

[0033] When training the large language model, obtain the sample traffic flow sequence corresponding to each intersection in the second historical time period, and determine the training sample set according to each sample traffic flow sequence. Optionally, each sample traffic flow sequence can be directly used as a sample traffic flow sequence in the training sample set. Then, for each sample traffic flow sequence in the training sample set, standardize each first sample traffic flow data in the sample traffic flow sequence to determine the corresponding second sample traffic flow data; then quantize each second traffic flow data in the preset historical window and the prediction window to determine the corresponding first sample quantized characters; wherein, the standardization and quantization process is similar to the above-mentioned process of standardizing and quantizing each first traffic flow data, and will not be repeated here. Then, each first sample quantized character in the preset historical window is input into the large language model to be trained, and the semantic vectors of each first sample quantized character are extracted respectively based on the generative pre-training model and the low-rank adaptation network in the large language model; determine the predicted quantized character of at least one sub-time period in the prediction window based on the semantic vector; and then determine the loss value according to the predicted quantized character and the first sample quantized character of at least one sub-time period in the prediction window; finally, train the large language model according to the loss value. This enables the large language model to have the ability to predict traffic flow.

[0034] In an optional implementation, training the large language model according to the loss value includes:

[0035] During the training process, the parameters of the generative pre-training model are fixed, and the model parameters of the low-rank adaptation network are updated according to the loss value.

[0036] The above technical solution has the following advantages or beneficial effects:

[0037] In order to improve the efficiency of large language model training, this application trains the large language model by fine-tuning the large language model. Specifically, during the training process, the parameters of the generative pre-trained model are fixed, and the model parameters of the low-rank adaptation network are updated according to the loss value. The parameters of the generative pre-trained model are pre-trained by the open source large language model, and the low-rank adaptation network is the network structure added to the large language model in this application.

[0038] In an optional implementation, the process of determining the training sample set includes:

[0039] Obtaining a sample traffic flow sequence corresponding to each intersection in the second historical time period;

[0040] According to each sample traffic flow sequence and each group of weight values, the traffic flow data of the corresponding time are weighted and summed to obtain each enhanced sample traffic flow sequence; according to each sample traffic flow sequence and each enhanced sample traffic flow sequence, the training sample set is determined; wherein, for each group of weight values, each weight value of the group is greater than 0, and the sum of each weight value of the group is 1.

[0041] The above technical solution has the following advantages or beneficial effects:

[0042] In order to improve the prediction performance of the trained large language model, the present application first enhances the sample traffic flow sequences corresponding to each intersection in the acquired second historical time period. That is, according to each sample traffic flow sequence and each group of weight values, the traffic flow data of the corresponding time is weighted and summed to obtain each enhanced sample traffic flow sequence; according to each sample traffic flow sequence and each enhanced sample traffic flow sequence, the training sample set is determined; wherein, for each group of weight values, each weight value of the group is greater than 0, and the sum of each weight value of the group is 1. Thus, the enhanced sample traffic flow sequence satisfies the non-negativity and normalization conditions. Then, based on each sample traffic flow sequence and each enhanced sample traffic flow sequence in the training sample set, the large language model is trained. Thereby, the prediction performance of the large language model is improved.

[0043] In a second aspect, the present application provides a traffic flow prediction device, the device comprising:

[0044] An acquisition module is used to acquire a traffic flow sequence in a first historical time period of a target intersection; wherein the traffic flow sequence includes first traffic flow data in each sub-time period arranged in chronological order; each first traffic flow data is standardized to determine corresponding second traffic flow data;

[0045] A determination module, used to quantify each second traffic flow data in a preset historical window, and determine each corresponding first quantized character; wherein the first quantized character is a character that can be recognized by the large language model;

[0046] The prediction module is used to input the first quantized characters into the large language model, determine the second quantized characters of at least one sub-time period within the prediction window based on the large language model; dequantize and denormalize the second quantized characters to determine the corresponding predicted traffic data.

[0047] In an optional embodiment, the acquisition module is specifically used to determine the average value and standard deviation of each of the first traffic flow data; for each of the first traffic flow data, determine the difference between the first traffic flow data and the average value, and determine the ratio of the difference to the standard deviation as the standardized second traffic flow data corresponding to the first traffic flow data.

[0048] In an optional embodiment, the determination module is specifically used to determine the number of segmentation intervals based on the first number of each second traffic flow data in the preset historical window and the second number of predicted traffic data preset in the prediction window; determine each segmentation interval and the quantization character corresponding to each segmentation interval based on the number of segmentation intervals and the percentile function of the standard normal distribution; determine the first segmentation interval to which the second traffic flow data belongs for each second traffic flow data; and determine the quantization character corresponding to the first segmentation interval as the first quantization character corresponding to the second traffic flow data.

[0049] In an optional embodiment, the prediction module is specifically used to determine the second segmentation interval corresponding to the second quantized character; determine two boundary values ​​of the second segmentation interval; and determine the average value of the two boundary values ​​as the value of the second quantized character after dequantization.

[0050] In an optional implementation, the prediction module is specifically used to determine the product of the inverse quantized value and the standard deviation; and determine the sum of the product and the average value as the corresponding predicted traffic data.

[0051] In an optional embodiment, the device further comprises:

[0052] A training module is used to obtain a sample traffic flow sequence corresponding to each intersection in a second historical time period, and determine a training sample set according to each sample traffic flow sequence; wherein the sample traffic flow sequence includes first sample traffic flow data in each sub-time period arranged in chronological order; for each sample traffic flow sequence in the training sample set, each first sample traffic flow data in the sample traffic flow sequence is standardized to determine the corresponding second sample traffic flow data; each second traffic flow data in a preset historical window and a prediction window is quantized to determine the corresponding first sample quantized characters; wherein the first sample quantized characters are characters that can be recognized by a large language model; each first sample quantized character in the preset historical window is input into a large language model to be trained, and based on a generative pre-training model and a low-rank adaptation network in the large language model, the semantic vectors of each first sample quantized character are respectively extracted; based on the semantic vector, a predicted quantized character of at least one sub-time period in the prediction window is determined; a loss value is determined according to the predicted quantized character and the first sample quantized character of at least one sub-time period in the prediction window; and the large language model is trained according to the loss value.

[0053] In an optional implementation, the training module is specifically used to fix the parameters of the generative pre-training model during the training process, and update the model parameters of the low-rank adaptation network according to the loss value.

[0054] In an optional embodiment, the training module is also used to obtain a sample traffic flow sequence corresponding to each intersection in the second historical time period; according to each sample traffic flow sequence and each group of weight values, the traffic flow data of the corresponding time is weighted and summed to obtain each enhanced sample traffic flow sequence; according to each sample traffic flow sequence and each enhanced sample traffic flow sequence, the training sample set is determined; wherein, for each group of weight values, each weight value of the group is greater than 0, and the sum of each weight value of the group is 1.

[0055] In a third aspect, the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;

[0056] Memory, used to store computer programs;

[0057] The processor is used to implement the method when executing the program stored in the memory.

[0058] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the described method is implemented.

[0059] In a fifth aspect, the present application provides a computer program product, wherein the computer program product comprises an executable program, and the executable program is executed by a processor to implement the described method. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0061] Figure 1 A schematic diagram of the first traffic flow prediction process provided for this application;

[0062] Figure 2 A schematic diagram of the second traffic flow prediction process provided for this application;

[0063] Figure 3 A schematic diagram of the process of determining each first quantized character provided by the present application;

[0064] Figure 4 A schematic diagram of the third traffic flow prediction process provided for this application;

[0065] Figure 5 A schematic diagram of the training process of the large language model provided for this application;

[0066] Figure 6 Schematic diagram of the traffic flow prediction model based on the large language fine-tuning model provided for this application;

[0067] Figure 7 Schematic diagram of traffic sequence tokenization provided for this application;

[0068] Figure 8 Schematic diagram of the framework of the LLaMA2 model based on LoRA fine-tuning provided in this application;

[0069] Fig. 9 A schematic diagram of the structure of the traffic flow prediction device provided in this application;

[0070] Fig.10 This is a schematic diagram of the electronic device structure provided in this application. DETAILED DESCRIPTION

[0071] In order to make the purpose and implementation method of the present application clearer, the exemplary implementation method of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, rather than all the embodiments.

[0072] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.

[0073] The terms "first", "second", "third", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances.

[0074] The terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.

[0075] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.

[0076] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

[0077] For the convenience of explanation, the above description has been made in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or limit the embodiments to the specific forms disclosed above. Based on the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are to better explain the principles and practical applications, so that those skilled in the art can better use the embodiments and various different variations of the embodiments suitable for specific use considerations.

[0078] This application proposes a traffic flow prediction method based on a large language model (LLM), and innovatively explores a traffic flow prediction method based on large language model technology. Considering that LLM lacks the ability to model traffic data features and cannot directly input traffic sequence data, a strategy for fine-tuning LLM is proposed to build a large language model suitable for traffic flow prediction. First, this application proposes a traffic sample enhancement mechanism based on time series hybrid crossover. For the different trend characteristics of traffic flow data at multiple intersections, the time series hybrid enhancement technology is used to expand a rich sample data set with different traffic evolution characteristics as a training sample set for fine-tuning LLM. Secondly, a quantitative strategy for converting traffic sequence data into token sequence data that can be recognized by LLM is proposed. This strategy uses the distribution characteristics of traffic sample data to achieve Gaussian distribution and equiprobability segmentation intervals, and then the original traffic sequence data can be mapped to intervals and converted into characters, thereby realizing token sequence conversion. Finally, in order to enable the large model to have the ability to model traffic flow features, the LoRA lightweight fine-tuning LLaMA2 large model (denoted as: T-LLaMA2) is used to train a prediction large model adapted to traffic flow data. In the prediction and reasoning stage, after obtaining the traffic character prediction results based on T-LLaMA2, the predicted characters are mapped to the distribution space of real traffic flow data through dequantization and denormalization operations to obtain the final traffic flow prediction results.

[0079] This application proposes a tokenization method for traffic sequence data, which realizes equal probability segmentation quantization based on Gaussian distribution quantiles, and effectively supports accurate prediction of traffic sequence based on LLM. A traffic flow prediction method based on a large language model is proposed. Through fine-tuning training, a large traffic flow sequence prediction model is constructed to improve the generalization adaptability of traditional small prediction models in different road environments, avoiding the high cost and scalability problems of training different prediction models for different scene data, and providing zero-shot prediction capabilities.

[0080] In recent years, with the vigorous development of large language model (LLM) technology represented by ChatGPT, LLM with zero-sample learning ability has shown great development potential in the field of time series prediction, which is due to the similarity of the mechanisms of time series prediction and word sequence prediction. In addition, LLM's own complex context-dependent modeling capabilities can enhance the time series prediction effect to a new level. However, traffic time series data and word sequence data are essentially heterogeneous data, and it is impractical to directly transfer traffic time series data to LLM. Therefore, this application proposes an adaptation mechanism to implement a traffic flow prediction method based on LLM, and realizes the construction of a training data set based on mixed sample enhancement. The traffic sequence is converted into a token sequence through a Gaussian distribution quantile quantization mechanism, and the low-rank adaptation network (Low-rank Adaptation, LoRA) strategy is used to fine-tune LLM to form a large traffic flow sequence prediction model, thereby realizing a unified traffic prediction model based on fine-tuning LLM, which can be extended to any intersection to achieve prediction.

[0081] Figure 1 The first traffic flow prediction process diagram provided for this application includes the following steps:

[0082] S101: Obtain a traffic flow sequence in a first historical time period of a target intersection; wherein the traffic flow sequence includes first traffic flow data in each sub-time period arranged in chronological order; and standardize each first traffic flow data to determine corresponding second traffic flow data;

[0083] S102: quantizing each second traffic flow data in a preset historical window to determine each corresponding first quantized character; wherein the first quantized character is a character that can be recognized by the large language model;

[0084] S103: Input each of the first quantized characters into the large language model, and determine a second quantized character of at least one sub-time period within a prediction window based on the large language model; dequantize and denormalize the second quantized character to determine corresponding predicted traffic data.

[0085] The traffic flow prediction method provided in the present application is applied to electrochromism, and the electronic device can be a PC, computer, server and other devices.

[0086] In the present application, the intersection for traffic flow prediction is taken as the target intersection. First, the traffic flow sequence in the first historical time period of the target intersection is obtained, wherein the traffic flow sequence includes the first traffic flow data in each sub-time period arranged in chronological order. For example, the sub-time period is a 5-minute time period, and the first historical time period is, for example, a time period of one day before the current time. The traffic flow sequence obtained in this way includes 288 first traffic flow data arranged in chronological order. Then, each first traffic flow data is standardized to determine the corresponding second traffic flow data. In other words, the 288 first traffic flow data are standardized to obtain the corresponding 288 second traffic flow data.

[0087] The electronic device quantizes each second traffic flow data in a preset historical window to determine each corresponding first quantized character; wherein the first quantized character is a character that can be recognized by the large language model. The preset historical window is, for example, a time period of 40 minutes before the current time, so that the preset historical window includes 8 second traffic flow data, and the electronic device quantizes the 8 second traffic flow data to determine the corresponding 8 first quantized characters. The electronic device is deployed with a trained large language model for traffic flow prediction, and each first quantized character is input into the large language model, and the second quantized character of at least one sub-time period in the prediction window is determined based on the large language model. The prediction window is, for example, 10 minutes after the current time, so that the second quantized characters corresponding to each of the two sub-time periods in the prediction window are determined based on the large language model, that is, two second quantized characters are obtained. For at least one second quantized character, the second quantized character is dequantized and denormalized to determine the predicted traffic data corresponding to the sub-time period corresponding to the second quantized character.

[0088] In order to solve the problem of poor accuracy of traffic flow prediction in the prior art, considering the advantages of the large language model, this application proposes a traffic flow prediction method based on a large language model. First, obtain the traffic flow sequence in the first historical time period of the target intersection; standardize each first traffic flow data of the traffic flow sequence to determine the corresponding second traffic flow data; then quantize each second traffic flow data in the preset historical window to determine the corresponding first quantized characters; then input each first quantized character into the large language model, and determine the second quantized character of at least one sub-time period in the prediction window based on the large language model; finally, dequantize and destandardize the second quantized character to determine the corresponding predicted traffic data. Thus, traffic flow prediction based on a large language model is realized. The problems of high generalization cost and poor scalability of existing traffic flow prediction based on statistics, machine learning and deep learning prediction models are avoided. The generalization performance of the traffic flow prediction model is improved.

[0089] Figure 2 The second traffic flow prediction process diagram provided for this application includes the following steps:

[0090] S201: Obtain a traffic flow sequence in a first historical time period of a target intersection; wherein the traffic flow sequence includes first traffic flow data in each sub-time period arranged in chronological order; determine an average value and a standard deviation of each first traffic flow data; for each first traffic flow data, determine a difference between the first traffic flow data and the average value, and determine a ratio of the difference to the standard deviation as standardized second traffic flow data corresponding to the first traffic flow data;

[0091] S202: quantizing each second traffic flow data in a preset historical window to determine each corresponding first quantized character; wherein the first quantized character is a character that can be recognized by the large language model;

[0092] S203: Input each of the first quantized characters into the large language model, and determine a second quantized character of at least one sub-time period within a prediction window based on the large language model; dequantize and denormalize the second quantized character to determine corresponding predicted traffic data.

[0093] In the present application, when standardizing each first traffic flow data, the average value and standard deviation of each first traffic flow data are first determined, and then for each first traffic flow data, the difference between the first traffic flow data and the average value is calculated, and then the ratio of the difference to the standard deviation is calculated, and the ratio is determined as the standardized second traffic flow data corresponding to the first traffic flow data. This improves the accuracy of traffic flow data standardization.

[0094] For example, the sub-time period is a 5-minute time period, and the first historical time period is, for example, a time period of one day before the current time. The traffic flow sequence thus obtained includes 288 first traffic flow data arranged in chronological order. The average value and standard deviation of the 288 first traffic flow data are determined; for the 288 first traffic flow data, the difference between the first traffic flow data and the average value is determined, and the ratio of the difference to the standard is determined as the standardized second traffic flow data corresponding to the first traffic flow data. 288 standardized second traffic flow data are obtained.

[0095] Figure 3 The schematic diagram of the process of determining each first quantized character provided in the present application includes the following steps:

[0096] S301: Determine the number of segmentation intervals according to the first number of each second traffic flow data in the preset historical window and the second number of the predicted traffic flow data preset in the prediction window; determine each segmentation interval and the quantization character corresponding to each segmentation interval according to the number of segmentation intervals and the percentile function of the standard normal distribution;

[0097] S302: for each of the second traffic flow data, determine the first segmentation interval to which the second traffic flow data belongs; and determine the quantization character corresponding to the first segmentation interval as the first quantization character corresponding to the second traffic flow data.

[0098] First, the first number of each second traffic flow data in the preset historical window is obtained. For example, the preset historical window is 40 minutes in history, and the sub-time period is 5 minutes, then the first number of each second traffic flow data in the preset historical window is 40 / 5=8. Then the second number of the preset predicted traffic flow data in the prediction window is obtained. For example, it is pre-specified that the traffic flow every 5 minutes in the next 10 minutes is predicted based on the historical data of 40 minutes, so the second number of the preset predicted traffic flow data in the prediction window is determined to be 10 / 5=2. The number of segmentation intervals is determined according to the first number and the second number. Optionally, the sum of the first number and the second number can be determined as the number of segmentation intervals. According to the number of segmentation intervals and the percentile function of the standard normal distribution, each segmentation interval and the quantization character corresponding to each segmentation interval are determined. Among them, according to the number of segmentation intervals and the percentile function of the standard normal distribution, the number of segmentation intervals minus 1 boundary value can be determined, and these boundary values ​​are arranged from small to large to obtain each segmentation interval. Among them, the smallest segmentation interval is from negative infinity to the smallest boundary value, and the largest segmentation interval is from the largest boundary value to positive infinity. For example, the quantization characters corresponding to each segment interval are 1 to 10 in order from small to large. That is, the quantization character corresponding to the smallest segment interval is 1, and the quantization character corresponding to the largest segment interval is 10. It should be noted that if the number of segment intervals is more than 10, the quantization character corresponding to the largest segment interval is a value greater than 10. For each second traffic flow data, the first segment interval to which the second traffic flow data belongs is first determined; then the quantization character corresponding to the first segment interval is determined as the first quantization character corresponding to the second traffic flow data. This improves the accuracy of the quantization of the traffic flow data.

[0099] Figure 4 The third traffic flow prediction process diagram provided for this application includes the following steps:

[0100] S401: Obtain a traffic flow sequence in a first historical time period of a target intersection; wherein the traffic flow sequence includes first traffic flow data in each sub-time period arranged in chronological order; determine an average value and a standard deviation of each first traffic flow data; for each first traffic flow data, determine a difference between the first traffic flow data and the average value, and determine a ratio of the difference to the standard deviation as standardized second traffic flow data corresponding to the first traffic flow data;

[0101] S402: quantizing each second traffic flow data in a preset historical window to determine each corresponding first quantized character; wherein the first quantized character is a character that can be recognized by the large language model;

[0102] S403: Input each of the first quantized characters into the large language model, and determine the second quantized character of at least one sub-time period within the prediction window based on the large language model; determine the second segmentation interval corresponding to the second quantized character; determine two boundary values ​​of the second segmentation interval; determine the average value of the two boundary values ​​as the value of the second quantized character after dequantization; determine the product of the dequantized value and the standard deviation; and determine the sum of the product and the average value as the corresponding predicted traffic data.

[0103] In the present application, each first quantized character is input into a large language model, and after the second quantized character of at least one sub-time period in the prediction window is determined based on the large language model, for at least one second quantized character, the second segmentation interval corresponding to the second quantized character is first determined; then the two boundary values ​​of the second segmentation interval are determined, and then the average value of the two boundary values ​​is determined, and the average value is determined as the value of the second quantized character after dequantization. Thereby improving the accuracy of the dequantization of the second quantized character. It should be noted that for the smallest segmentation interval, that is, the segmentation interval from negative infinity to the smallest boundary value, the smallest boundary value can be used as the average value corresponding to the smallest segmentation interval; for the largest segmentation interval, that is, the segmentation interval from the maximum boundary value to positive infinity, the maximum boundary value can be used as the average value corresponding to the largest segmentation interval.

[0104] In the present application, for each second quantized character, after determining the inverse quantized value corresponding to the second quantized character, the product of the inverse quantized value and the standard deviation is calculated; then the sum of the product and the average value is determined as the predicted traffic data corresponding to the inverse quantized value. Thus, traffic flow prediction based on a large language model is achieved. It should be noted that the standard deviation and the average value are the average value and standard deviation of each determined first traffic flow data.

[0105] Figure 5The schematic diagram of the training process of the large language model provided for this application includes the following steps:

[0106] S501: Obtain a sample traffic flow sequence corresponding to each intersection in a second historical time period, and determine a training sample set according to each sample traffic flow sequence; wherein the sample traffic flow sequence includes first sample traffic flow data in each sub-time period arranged in chronological order;

[0107] S502: for each sample traffic flow sequence in the training sample set, standardize each first sample traffic flow data in the sample traffic flow sequence to determine the corresponding second sample traffic flow data; quantize each second traffic flow data in the preset historical window and the prediction window to determine the corresponding first sample quantized characters; wherein the first sample quantized characters are characters that can be recognized by the large language model;

[0108] S503: Input each first sample quantized character in the preset historical window into the large language model to be trained, and extract the semantic vector of each first sample quantized character based on the generative pre-training model and the low-rank adaptation network in the large language model; determine the predicted quantized character of at least one sub-time period in the prediction window based on the semantic vector; determine the loss value according to the predicted quantized character and the first sample quantized character of at least one sub-time period in the prediction window; and train the large language model according to the loss value.

[0109] When training the large language model, obtain the sample traffic flow sequence corresponding to each intersection in the second historical time period, and determine the training sample set according to each sample traffic flow sequence. Optionally, each sample traffic flow sequence can be directly used as a sample traffic flow sequence in the training sample set. Then, for each sample traffic flow sequence in the training sample set, standardize each first sample traffic flow data in the sample traffic flow sequence to determine the corresponding second sample traffic flow data; then quantize each second traffic flow data in the preset historical window and the prediction window to determine the corresponding first sample quantized characters; wherein, the standardization and quantization process is similar to the above-mentioned process of standardizing and quantizing each first traffic flow data, and will not be repeated here. Then, each first sample quantized character in the preset historical window is input into the large language model to be trained, and the semantic vectors of each first sample quantized character are extracted respectively based on the generative pre-training model and the low-rank adaptation network in the large language model; determine the predicted quantized character of at least one sub-time period in the prediction window based on the semantic vector; and then determine the loss value according to the predicted quantized character and the first sample quantized character of at least one sub-time period in the prediction window; finally, train the large language model according to the loss value. This enables the large language model to have the ability to predict traffic flow.

[0110] In the present application, training the large language model according to the loss value includes:

[0111] During the training process, the parameters of the generative pre-training model are fixed, and the model parameters of the low-rank adaptation network are updated according to the loss value.

[0112] In order to improve the efficiency of large language model training, this application trains the large language model by fine-tuning the large language model. Specifically, during the training process, the parameters of the generative pre-trained model are fixed, and the model parameters of the low-rank adaptation network are updated according to the loss value. The parameters of the generative pre-trained model are pre-trained by the open source large language model, and the low-rank adaptation network is the network structure added to the large language model in this application.

[0113] In this application, the process of determining the training sample set includes:

[0114] Obtaining a sample traffic flow sequence corresponding to each intersection in the second historical time period;

[0115] According to each sample traffic flow sequence and each group of weight values, the traffic flow data of the corresponding time are weighted and summed to obtain each enhanced sample traffic flow sequence; according to each sample traffic flow sequence and each enhanced sample traffic flow sequence, the training sample set is determined; wherein, for each group of weight values, each weight value of the group is greater than 0, and the sum of each weight value of the group is 1.

[0116] In order to improve the prediction performance of the trained large language model, the present application first enhances the sample traffic flow sequences corresponding to each intersection in the acquired second historical time period. That is, according to each sample traffic flow sequence and each group of weight values, the traffic flow data of the corresponding time is weighted and summed to obtain each enhanced sample traffic flow sequence; according to each sample traffic flow sequence and each enhanced sample traffic flow sequence, the training sample set is determined; wherein, for each group of weight values, each weight value of the group is greater than 0, and the sum of each weight value of the group is 1. Thus, the enhanced sample traffic flow sequence satisfies the non-negativity and normalization conditions. Then, based on each sample traffic flow sequence and each enhanced sample traffic flow sequence in the training sample set, the large language model is trained. Thereby, the prediction performance of the large language model is improved.

[0117] The traffic flow prediction process provided by this application is described in detail below with reference to the accompanying drawings.

[0118] Figure 6 The schematic diagram of the traffic flow prediction model based on the large language fine-tuning model provided for this application includes the following steps:

[0119] S1: traffic data sample enhancement;

[0120] S2: flow data scaling and quantification;

[0121] S21: Standard normalization of traffic data; S22: Gaussian distribution quantile delineation quantification interval; S23: Symbol conversion of traffic series data;

[0122] S3: Fine-tuning training of large language model LoRA;

[0123] S4: Dequantization and descaling of predicted output.

[0124] This application proposes a traffic flow prediction method based on a large language model (LLM). Considering that LLM lacks traffic data features and cannot directly input traffic sequence data, a strategy for fine-tuning LLM is proposed to build a large language model suitable for traffic flow prediction. First, this application proposes a traffic sample enhancement mechanism based on time series hybrid crossover. In view of the different trend characteristics of traffic flow data at multiple intersections, the time series hybrid enhancement technology is used to expand a rich sample data set with different traffic evolution characteristics as a training sample set for fine-tuning LLM. Secondly, a quantitative strategy for converting traffic sequence data into token sequence data that can be recognized by LLM is proposed. This strategy uses the distribution characteristics of traffic sample data to realize the interval division based on Gaussian distribution and equiprobability segmentation, and then the original traffic sequence data can be mapped to interval characters, thereby realizing token sequence conversion. Finally, in order to enable the large model to have the ability to model traffic flow characteristics, the LoRA lightweight fine-tuning LLaMA2 large model (denoted as: T-LLaMA2) is used to train a prediction large model adapted to traffic flow data. In the prediction and reasoning stage, after obtaining the traffic character prediction results based on T-LLaMA2, the predicted characters are mapped to the distribution space of real traffic flow data through dequantization and descaling operations to obtain the final traffic flow prediction results.

[0125] The method provided in this application explores the application of large language models in intelligent transportation systems, constructs a large vertical traffic prediction model suitable for the field of traffic prediction, and uses a unified model to achieve more efficient, accurate, and highly generalized traffic prediction, making traffic control more intelligent.

[0126] The purpose of this application is to provide a traffic flow prediction method based on a large language model, which is used to improve the problem that the traditional traffic prediction model is limited to a specific model and has poor generalization performance. Specifically, the traffic flow prediction method based on a large language model involved in this application includes the following steps:

[0127] Assume a traffic network consisting of n intersections, each of which is equipped with flow monitoring sensors (such as electric police, checkpoints, etc.). In order to build a unified model to achieve efficient and accurate prediction of traffic flows at n intersections, this application proposes a traffic flow prediction method based on a large language model, which realizes flow prediction large model training and inference prediction through flow data enhancement, flow data quantization and labeling, large model fine-tuning training, and prediction output dequantization and descaling.

[0128] S1: Traffic data sample enhancement.

[0129] In the training phase, since the sample sequences that can be collected are limited by the number of sensors, the prediction ability of the large model may be weak. In order to train a traffic flow prediction model with strong generalization ability, this application uses time series hybrid enhancement technology to expand the corpus of the original collected multi-intersection traffic data.

[0130] Specifically, in order to enhance the prediction generalization ability of the large model, the traffic data sample enhancement technology based on time series hybrid enhancement is implemented to expand the original traffic data X 0 Forming enhanced sample X 1 , and then form a rich traffic sample data set X = {X 0 ,X 1}. Where X 0 It consists of n traffic sequences at intersections, X 1 It consists of m enhanced sample traffic sequences.

[0131] The concept of time series mixing is to randomly sample several segments from different traffic flow time series, and then mix them together in a certain proportion to generate a new traffic flow series. This process can be formalized as follows: in arrive are k time series segments sampled from the original traffic dataset, λ1 to λ k is the corresponding mixing coefficient, satisfying the non-negativity and normalization conditions, By adjusting k and λ, time series with different diversity and complexity can be generated.

[0132] Although the traffic sequence generated based on the time series hybrid technology is artificially synthesized, it can simulate the time series evolution patterns of various traffic trends in the real world. Adding this synthetic enhanced data to the pre-training corpus can improve the generalization ability and robustness of the large model in traffic prediction.

[0133] S2: Flow data scaling and quantification.

[0134] The general large language model is a deep learning prediction model trained on massive text data, and its input adaptation format is text corpus data. Traffic flow data is a flow time series data that cannot be directly input into LLM for prediction. Therefore, this application proposes a new flow data quantization strategy, which converts traffic flow data into a token sequence suitable for LLM input through scaling and quantization, so that the (fine-tuned) large language model can be used for flow prediction.

[0135] S21: Normalization of traffic data standards.

[0136] First, in order to reduce the subsequent computational complexity and reduce the cost of large model training and inference, a scaling strategy can be used to map traffic flow data of different scales to an appropriate range. This application uses the z-score standardization method to scale the original training sample sequence into a new sample x′:

[0137]

[0138] Where μ and σ represent the mean and standard deviation of the feature dimension to which the training samples belong.

[0139] S22: Gaussian distribution quantile delineation quantitative interval.

[0140] Assume that the scaled sequence is x′ 1:H+F =[x ′ 1,…,x ′ H ,…,x′ H+F ], where H represents the historical correlation time step and F represents the prediction time step. The initial scaled sequence x′ 1:H+F It is still a real value and cannot be directly processed by the language model. In order to convert these real values ​​into discrete symbols, this application uses quantization technology to convert real traffic into token sequences.

[0141] Mapping continuous real values ​​to discrete token IDs is equivalent to dividing the real number axis into several intervals. Assume that C bucket centers b are selected on the real number domain. 1:C , satisfying b1<… C , there are C-1 edges c i Split these buckets to satisfy b i <c i i+1 ,i∈{1,…,C-1}.

[0142] In order to make the divided bins have equal probability distribution, Gaussian distribution quantiles are used to define the segmentation intervals. The standardized time series is assumed to have a normal distribution, satisfying x ′ ~N(0,1), so the discrete interval can be constructed by the normal distribution quantile.​​

[0143] Specifically, this application uses the percentile point function of the standard normal distribution to obtain the Z score (the location of the split point). For C bucket centers, calculate C-1 quantiles p 1:C-1 , and then calculate the number of percentile points of the standard normal distribution for each quantile, that is, the split edge c i .

[0144] φ(c i )≤p i ; φ(·) uses the norm object from the scipy.stats library to calculate the percentile number.

[0145] For example, assuming the partition interval is C = 10, the percentile points calculated are as follows:

[0146] c 1:9 ={-1.28,-0.84,-0.52,-0.25,0,0.25,0.52,0.84,1.28}.

[0147] The 10 intervals divided by quantiles are

[0148] S23: Traffic sequence data symbol conversion.

[0149] After obtaining the quantized segmentation interval, the scaled flow sequence x ′ Quantification is converted into a string sequence. The specific formula is as follows:

[0150]

[0151] In addition, in addition to the traffic sequence tokens list {1, 2, ..., C}, a special marker EOS is added to represent the end of the sequence to facilitate the understanding of the large language model.

[0152] Finally, the original sequence x′ 1:H+F will be converted into a character sequence z through tokenization 1:H+F For subsequent LLM traffic prediction model training and prediction reasoning.

[0153] In summary, this application can tokenize the original traffic sequence. Figure 7Schematic diagram of traffic sequence tokenization provided for this application. It is assumed that the number of buckets is 10. The original traffic sequence is {23, 35, 46, 123, 222, 245, 102, 33, 22, 28}; scaled traffic sequence (standardized): {-0.81, -0.66, -0.52, 0.43, 1.67, 1.96, 0.17, -0.68, -0.82, -0.74}; quantized character sequence: {3, 3, 4, 7, 10, 10, 6, 3, 3, 3}; output character sequence: {3, 3, 4, 7, 10, 10, 6, 3, 3, 3, EOS}.

[0154] S3: Fine-tuning training of the large language model LoRA.

[0155] In order to obtain a large language model that can understand the evolution characteristics of traffic flow sequences, this application fine-tunes the open source LLaMA2 large language model. Specifically, the LoRA method is used to train the model to obtain a large language prediction model for traffic sequences.

[0156] LoRA is a novel technique that solves the problem of efficiently fine-tuning large language models. LoRA greatly reduces the number of training parameters and memory requirements by freezing the weights of the pre-trained model and injecting trainable layers (rank factorization matrices) into each Transformer block.

[0157] Assume that the sequence data after traffic mark conversion is z 1:H+F , then the model receives the input data z 1:H After that, the prediction result can be output H+1:H+F , through the predicted value and the true value z H+1:H+F The training model can be obtained by minimizing the error between the two.

[0158] This application is fine-tuned based on the open source large model LLaMA2. The parameters that need to be updated are as follows:

[0159] W0+ΔW;

[0160] Where W0 is the initialization parameter of the pre-trained model LLaMA2, and ΔW is the parameter that needs to be fine-tuned and updated. To achieve lightweight model fine-tuning, W0 can be frozen and only ΔW can be updated.

[0161] Assume that the LLaMA2 pre-training matrix is Then the fine-tuning model parameter update process can be expressed as:

[0162]

[0163] The rank r<<min(d,k). Then the model training process can be completed by minimizing the error back propagation optimization.

[0164] Figure 8 The framework diagram of the LLaMA2 model based on LoRA fine-tuning provided for this application is as follows: Figure 8 As shown in the figure, the LlaMA2 pre-training weights are the weights of the generative pre-training model, and the dimension reduction matrix A and the dimension increase matrix B are low-rank adaptation networks. H ,…,z H+F} are respectively input into the generative pre-training model and the low-rank adaptation network, and the semantic vectors of the traffic character sequence data are respectively extracted based on the generative pre-training model and the low-rank adaptation network; the traffic character prediction data {o H+1 ,…,o H+F}.

[0165] S4: Dequantization and descaling of predicted output.

[0166] The large language model that has undergone the above fine-tuning process can predict traffic character sequence data. After obtaining the character sequence output, it is necessary to map the character sequence to real traffic data through dequantization and descaling operations.

[0167] First, according to the Gaussian distribution quantile quantization interval segmentation rule, the inverse quantization operation is defined as follows:

[0168]

[0169] Among them, b j Indicates the center of the jth bucket, that is, the center position of the bucket. The predicted character sequence can be converted into a numerical sequence d through the dequantization operation.

[0170] Then, the anti-standard normalization technique is used to map the prediction results to the traffic data in the original scale that conforms to the real scene.

[0171]

[0172] Through the above ideas, the fine-tuned T-LLaMA2 large language model can be used to effectively predict the traffic flow at any intersection in a large-scale traffic network.

[0173] Fig. 9 This is a schematic diagram of the structure of the traffic flow prediction device provided in this application, and the device includes:

[0174] The acquisition module 21 is used to acquire a traffic flow sequence in a first historical time period of the target intersection; wherein the traffic flow sequence includes first traffic flow data in each sub-time period arranged in chronological order; each first traffic flow data is standardized to determine the corresponding second traffic flow data;

[0175] A determination module 22, configured to quantize each second traffic flow data in a preset historical window and determine each corresponding first quantized character; wherein the first quantized character is a character that can be recognized by the large language model;

[0176] The prediction module 23 is used to input the first quantized characters into the large language model, determine the second quantized characters of at least one sub-time period within the prediction window based on the large language model; dequantize and denormalize the second quantized characters to determine the corresponding predicted traffic data.

[0177] In an optional embodiment, the acquisition module 21 is specifically used to determine the average value and standard deviation of each of the first traffic flow data; for each of the first traffic flow data, determine the difference between the first traffic flow data and the average value, and determine the ratio of the difference to the standard deviation as the standardized second traffic flow data corresponding to the first traffic flow data.

[0178] In an optional embodiment, the determination module 22 is specifically used to determine the number of segmentation intervals based on the first number of each second traffic flow data in the preset historical window and the second number of predicted traffic data preset in the prediction window; determine each segmentation interval and the quantization character corresponding to each segmentation interval based on the number of segmentation intervals and the percentile function of the standard normal distribution; determine the first segmentation interval to which the second traffic flow data belongs for each second traffic flow data; and determine the quantization character corresponding to the first segmentation interval as the first quantization character corresponding to the second traffic flow data.

[0179] In an optional embodiment, the prediction module 23 is specifically used to determine the second segmentation interval corresponding to the second quantized character; determine two boundary values ​​of the second segmentation interval; and determine the average value of the two boundary values ​​as the value of the second quantized character after dequantization.

[0180] In an optional implementation, the prediction module 23 is specifically configured to determine the product of the inverse quantized value and the standard deviation; and determine the sum of the product and the average value as the corresponding predicted traffic data.

[0181] In an optional embodiment, the device further comprises:

[0182] The training module 24 is used to obtain the sample traffic flow sequence corresponding to each intersection in the second historical time period, and determine the training sample set according to the sample traffic flow sequence; wherein the sample traffic flow sequence includes the first sample traffic flow data in each sub-time period arranged in chronological order; for each sample traffic flow sequence in the training sample set, each first sample traffic flow data in the sample traffic flow sequence is standardized to determine the corresponding second sample traffic flow data; each second traffic flow data in the preset historical window and the prediction window is quantized to determine the corresponding first sample quantized characters; wherein the first sample quantized characters are characters that can be recognized by the large language model; each first sample quantized character in the preset historical window is input into the large language model to be trained, and based on the generative pre-training model and the low-rank adaptation network in the large language model, the semantic vectors of each first sample quantized character are respectively extracted; based on the semantic vector, the predicted quantized character of at least one sub-time period in the prediction window is determined; according to the predicted quantized character and the first sample quantized character of at least one sub-time period in the prediction window, a loss value is determined; and the large language model is trained according to the loss value.

[0183] In an optional implementation, the training module 24 is specifically configured to fix the parameters of the generative pre-training model during the training process, and update the model parameters of the low-rank adaptation network according to the loss value.

[0184] In an optional embodiment, the training module 24 is also used to obtain a sample traffic flow sequence corresponding to each intersection in the second historical time period; according to each sample traffic flow sequence and each group of weight values, the traffic flow data of the corresponding time is weighted and summed to obtain each enhanced sample traffic flow sequence; according to each sample traffic flow sequence and each enhanced sample traffic flow sequence, the training sample set is determined; wherein, for each group of weight values, each weight value of the group is greater than 0, and the sum of each weight value of the group is 1.

[0185] The present application also provides an electronic device, such as Fig.10 As shown, it includes: a processor 31, a communication interface 32, a memory 33 and a communication bus 34, wherein the processor 31, the communication interface 32, and the memory 33 communicate with each other through the communication bus 34;

[0186] The memory 33 stores a computer program, and when the program is executed by the processor 31, the processor 31 executes any one of the above method steps.

[0187] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0188] The communication interface 32 is used for communication between the above electronic device and other devices.

[0189] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0190] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.

[0191] The present application also provides a computer storage readable storage medium, wherein the computer readable storage medium stores a computer program executable by an electronic device, and when the program runs on the electronic device, the electronic device implements any of the above method steps when executing.

[0192] The present application provides a computer program product, wherein the computer program product comprises an executable program, and when the executable program is executed by a processor, the method described above is implemented.

[0193] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0194] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A traffic flow prediction method, characterized in that: The method comprises: Acquire a traffic flow sequence in a first historical time period of the target intersection; wherein the traffic flow sequence includes first traffic flow data in each sub-time period arranged in chronological order; standardize each first traffic flow data to determine corresponding second traffic flow data; Quantifying each second traffic flow data in a preset historical window to determine each corresponding first quantized character; wherein the first quantized character is a character that can be recognized by the large language model; The first quantized characters are input into the large language model, and a second quantized character of at least one sub-time period within a prediction window is determined based on the large language model; the second quantized characters are dequantized and denormalized to determine corresponding predicted traffic data.

2. The method according to claim 1, characterized in that The step of normalizing each first traffic flow data to determine the corresponding second traffic flow data includes: Determine the average value and standard deviation of each of the first traffic flow data; for each of the first traffic flow data, determine the difference between the first traffic flow data and the average value, and determine the ratio of the difference to the standard deviation as the standardized second traffic flow data corresponding to the first traffic flow data.

3. The method according to claim 2, characterized in that The step of quantizing each second traffic flow data in the preset historical window to determine each corresponding first quantization character comprises: Determine the number of segmentation intervals according to the first number of each second traffic flow data in the preset historical window and the second number of the predicted traffic flow data preset in the prediction window; determine each segmentation interval and the quantization character corresponding to each segmentation interval according to the number of segmentation intervals and the percentile function of the standard normal distribution; For each of the second traffic flow data, determine the first segmentation interval to which the second traffic flow data belongs; and determine the quantization character corresponding to the first segmentation interval as the first quantization character corresponding to the second traffic flow data.

4. The method according to claim 3, characterized in that The process of dequantizing the second quantized character includes: Determine a second segmentation interval corresponding to the second quantized character; determine two boundary values ​​of the second segmentation interval; and determine an average value of the two boundary values ​​as the value of the second quantized character after dequantization.

5. The method according to claim 4, characterized in that De-normalizing the de-quantized value of the second quantized character to determine the corresponding predicted traffic data includes: Determine the product of the inverse quantized value and the standard deviation; and determine the sum of the product and the average value as the corresponding predicted flow data.

6. The method according to claim 1, characterized in that The training process of the large language model includes: Obtaining a sample traffic flow sequence corresponding to each intersection in the second historical time period, and determining a training sample set according to each sample traffic flow sequence; wherein the sample traffic flow sequence includes first sample traffic flow data in each sub-time period arranged in chronological order; For each sample traffic flow sequence in the training sample set, each first sample traffic flow data in the sample traffic flow sequence is standardized to determine the corresponding second sample traffic flow data; each second traffic flow data in a preset historical window and a prediction window is quantized to determine the corresponding first sample quantized characters; wherein the first sample quantized characters are characters that can be recognized by the large language model; Input each first sample quantized character in the preset historical window into the large language model to be trained, and extract the semantic vector of each first sample quantized character based on the generative pre-training model and the low-rank adaptation network in the large language model; determine the predicted quantized character of at least one sub-time period in the prediction window based on the semantic vector; determine the loss value according to the predicted quantized character and the first sample quantized character of at least one sub-time period in the prediction window; and train the large language model according to the loss value.

7. The method according to claim 6, characterized in that Training the large language model according to the loss value includes: During the training process, the parameters of the generative pre-training model are fixed, and the model parameters of the low-rank adaptation network are updated according to the loss value.

8. The method according to claim 6, characterized in that The process of determining the training sample set includes: Obtaining a sample traffic flow sequence corresponding to each intersection in the second historical time period; According to each sample traffic flow sequence and each group of weight values, the traffic flow data of the corresponding time are weighted and summed to obtain each enhanced sample traffic flow sequence; according to each sample traffic flow sequence and each enhanced sample traffic flow sequence, the training sample set is determined; wherein, for each group of weight values, each weight value of the group is greater than 0, and the sum of each weight value of the group is 1.

9. A traffic flow prediction device, characterized in that: The device comprises: An acquisition module is used to acquire a traffic flow sequence in a first historical time period of a target intersection; wherein the traffic flow sequence includes first traffic flow data in each sub-time period arranged in chronological order; each first traffic flow data is standardized to determine corresponding second traffic flow data; A determination module, used to quantify each second traffic flow data in a preset historical window, and determine each corresponding first quantized character; wherein the first quantized character is a character that can be recognized by the large language model; The prediction module is used to input the first quantized characters into the large language model, determine the second quantized characters of at least one sub-time period within the prediction window based on the large language model; dequantize and denormalize the second quantized characters to determine the corresponding predicted traffic data.

10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method according to any one of claims 1 to 8 when executing a program stored in a memory.

Citation Information

Patent Citations

  • Traffic flow smoothness grade evaluating method and system

    CN102044153A

  • Personalized traffic accident risk prediction and recommendation method based on depth learning

    CN109117987A

  • Application program traffic identification method under VPN based on distribution characteristic random forest

    CN110460502A

  • Translation model compression method, translation method and related device

    CN114662485A

  • Passenger flow volume prediction method, device, equipment and storage medium

    CN115239022A

Cited By

  • State prediction method and head-mounted display device

    CN120744328A