A semantic-driven traffic simulation scenario generation method based on a large language model
By combining a large language model with a knowledge base and surrogate distillation training techniques, the problems of low automation and high computational resource consumption in existing traffic simulation methods are solved, achieving efficient and accurate traffic simulation scene generation, and capable of handling complex and dynamic traffic scenarios.
Patent Information
- Application Number
- CN202511882215.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-15
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2045-12-15
AI Technical Summary
Existing traffic simulation methods rely on manual input and configuration, which makes it difficult to guarantee the accuracy and flexibility of simulation results. They also consume a lot of computing resources and lack the ability to make intelligent inferences about complex traffic scenarios and dynamic changes, making it difficult to generate high-precision and highly automated simulation scenarios.
By combining a large language model with a knowledge base, semantic enhancement and tool retrieval are performed using the RAG-MCP mechanism. A lightweight student model is trained using surrogate distillation to generate structured simulation configurations through multi-step reasoning. Combined with the traffic knowledge base, actual travel patterns are inferred to generate simulation scenarios that conform to actual traffic flow.
It significantly improves the automation and generation efficiency of simulation scenarios, reduces computational complexity, enhances the accuracy and controllability of simulation results, and can flexibly handle dynamic changes to generate reasonable OD flow and realistic simulation scenarios.
Smart Images

Figure CN121328352B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of traffic simulation, in particular to a semantic-driven traffic simulation scene generation method based on a large language model. BACKGROUND
[0002] With the increasing complexity and scale of urban traffic networks, traditional traffic simulation methods face great challenges. Existing traffic simulation systems usually rely on manual input and manual configuration of traffic networks, travel demand and traffic signals and other elements, which not only consumes time and resources, but also makes it difficult to ensure the accuracy and flexibility of the simulation results. With the advancement of artificial intelligence technology, especially the development of large language models (LLM), data-driven automated traffic simulation methods have gradually become a research hotspot.
[0003] Currently, although there are some artificial intelligence-based traffic simulation methods, most of them still rely on rule engines or fixed model structures, lacking intelligent reasoning capabilities for complex traffic scenarios and dynamic changes. In addition, existing methods often require a large amount of computing resources when processing large-scale traffic data, and it is difficult to balance efficiency and accuracy. Existing traffic simulation systems are also not sensitive to user needs, lack of integration with real-time data, making it difficult to accurately reflect real-world traffic flow and emergencies in the simulation scene.
[0004] Chinese patent CN119598726A discloses an automatic driving test scene generation framework and method, which adopts a multi-modal large language model based on prompt engineering to interact with a traffic simulation tool, generates node files and edge files, integrates road network files and vehicle models, constructs a traffic simulation mechanism, and generates customized automatic driving test scenes. Although this method uses a multi-modal large language model and prompt word engineering to realize the conversion from natural language description to simulation configuration file, its core method still stays at the level of template-based formatted output and post-correction, which has the following defects: it lacks a deep semantic understanding and structured analysis mechanism for natural language input, and its dependent prompt word engineering and performance evaluator are more likely to generate code format files through pre-set templates and perform iterative path correction, resulting in deficiencies in semantic understanding accuracy, scene generation structure, controllability of the reasoning process, and reliability of the generated results, making it difficult to achieve high-precision, high-automation, and semantic-driven traffic simulation scene generation. SUMMARY
[0005] The application aims to provide a semantic-driven traffic simulation scene generation method based on a large language model, which combines natural language input with a knowledge base, utilizes the emergent ability of a large language model and traffic flow modeling technology to automatically generate a traffic simulation scene that conforms to actual travel rules, and effectively solves the problems of low automation, poor computational efficiency, inaccurate simulation results and the like in the prior art.
[0006] The application aims to provide a semantic-driven traffic simulation scene generation method based on a large language model, which combines natural language input with a knowledge base, utilizes the emergent ability of a large language model and traffic flow modeling technology to automatically generate a traffic simulation scene that conforms to actual travel rules, and effectively solves the problems of low automation, poor computational efficiency, inaccurate simulation results and the like in the prior art.
[0007] A semantic-driven traffic simulation scene generation method based on a large language model, comprising the following steps:
[0008] S1, receiving a traffic simulation scene natural language description input by a user;
[0009] S2, constructing a tool knowledge base and vectorizing and encoding the user input to obtain input semantic encoding, calculating the similarity of the input semantic encoding and each tool description in the tool knowledge base, retrieving a plurality of related tool descriptions, and merging the user input to obtain an extended input;
[0010] S3, calling a large language model to perform multi-step reasoning on the extended input, determining the tools in the tool knowledge base that need to be called, and generating structured simulation configuration elements using the determined tools; wherein the large language model is trained based on a distillation learning method, and the teacher model first-step thinking chain reasoning is introduced as a prefix in the distillation process;
[0011] S4, converting the generated simulation configuration elements into a configuration file that can be directly loaded into a traffic simulation platform, and performing simulation verification in the traffic simulation platform.
[0012] The traffic simulation scene natural language description input by the user includes a traffic scene type, a region name or geographic coordinates, a time condition, a weather factor, a road level and a signal control mode, a travel demand feature, and a special event, the time condition includes a peak, a non-peak or a time period, and the special event includes an accident, a construction or a regulation.
[0013] The simulation configuration elements include a road network topology structure, a region mapping and function labeling, a traffic signal control scheme, a vehicle type and behavior rule, an event / weather influence parameter and a traffic flow OD (Origin-Destination) demand distribution, wherein the traffic signal control scheme includes timing and phase.
[0014] The S2 specifically comprises the following steps:
[0015] S21, constructing a tool knowledge base using a RAG-MCP (Retrieval-Augmented Generation - Model Context Protocol) tool, storing the functions, parameters, examples, MCP (Model Context Protocol) templates and executable interface descriptions of the tool, and realizing semantic enhancement and efficient tool retrieval;
[0016] S22, mapping the user input and each tool description in the tool knowledge base into vector representations through a text embedding model to obtain input semantic encoding and tool description vectors, respectively;
[0017] S23, calculating the cosine similarity of the input semantic encoding and the tool description vectors in the tool knowledge base, sorting the tool knowledge base according to the cosine similarity and selecting the top most relevant tools;
[0018] S24, splicing the tool descriptions of the top most relevant tools and the original user input to form an extended input.
[0019] The proxy distillation loss function of the large language model is constructed by combining the cross-entropy loss of the large language model inference response and action and the behavior regularization term to constrain the student model to select executable and reasonable action sequences to complete the model training.
[0020] The training process of the large language model includes the following steps:
[0021] The guided teacher model is given an extended input and a proxy instruction to interact with the tool chain / simulation environment, and generate a teacher trajectory:
[0022] ,
[0023] wherein, represents the inference / natural language response of the th sampling point in the trajectory, represents the action / tool call of the th sampling point in the trajectory, represents the tool or environment observation of the th sampling point in the trajectory, represents the length of the generated trajectory , is the output of the teacher model for a given extended input and a proxy instruction .
[0024] To improve distillation stability, the thought chain reasoning from the first step of the teacher model is introduced as a prefix during the distillation process, thus updating the generation trajectory of the teacher model:
[0025] ,
[0026] in, This represents the first step of the teacher model's thought process reasoning. It serves as a prompt to guide the teacher in generating the initial inference steps of the model. Given extended input With tips Teacher Model The output, Indicating integration The first step of reasoning for the subsequent intelligent agent. Given extended input With agent instructions Next, integration Post-Teacher Model The output;
[0027] Training lightweight student models By focusing on teacher models Behavioral sequences instead of directly optimizing observations Knowledge transfer is achieved by minimizing the following distillation losses:
[0028] ,
[0029] in, This represents the probability that the student model generates the current reasoning and action given all previous reasoning, actions, and observations. , indicating the result of previous reasoning; It is a training dataset of teacher trajectories containing various tasks; Describe the process by which the teacher model generates a complete interaction trajectory under the prompting of the agent; For the parameters of the student model; Let be the expected function. Indicates in Obey the training dataset Under the distribution, for Seeking expectations.
[0030] Specifically, S3 involves the large language model performing multi-stage reasoning to generate a language model that... A series of sequentially generated simulation configuration elements The simulation configuration consists of elements for stage t, where the simulation configuration elements for stage t are... The generation process includes the following steps:
[0031] S31, expand the input and tool knowledge base input large language model, combined with the retrieval results of step S2, determine the tool set to be executed in this stage of simulation configuration element generation :
[0032] ,
[0033] wherein, represents the large language model, represents the set of the first most relevant tools retrieved in step S2;
[0034] S32, based on the previously generated elements of this simulation configuration element generation , the current knowledge base and the selected tool set , generate the simulation configuration elements of the first stage :
[0035] ,
[0036] wherein, represents the currently invoked knowledge base, when the simulation configuration element generated in this stage is the traffic flow OD demand distribution, take the traffic knowledge base, when the simulation configuration element generated in this stage is other than the traffic flow OD demand distribution, take the tool knowledge base, represents a structured simulation configuration generation function;
[0037] repeat the above steps S31 and S32 until a complete set of simulation configuration elements is formed .
[0038] In the process of generating traffic flow OD demand distribution in the structured simulation configuration element generated by the determined tool, the process includes the following steps:
[0039] Based on the place name and the range radius in the user input, obtain the bounding box , that is, the geographical range latitude and longitude, and extract the administrative division ;
[0040] Download network data from external road network sources and convert it into a SUMO (Simulation of Urban Mobility, a certain open source microscopic traffic simulation software) network , extract the node set With edge set ;
[0041] Map the roads in the road network to administrative divisions to obtain , extract the functional attributes of each node in each division ;
[0042] Use large language model LLM and traffic knowledge base Infer node potential for each pair of regions , including origin potential and attraction potential :
[0043] ,
[0044] Wherein, represents the type of origin node, represents the type of destination node, is the adjacency matrix of the road network, representing its topological structure and hierarchical information;
[0045] Convert the node potential and the impedance between nodes in the time period to the predicted OD flow from node to node :
[0046] ,
[0047] Wherein, represents the predicted OD flow from node to node in time interval , is the impedance function, is the origin potential in time interval , is the attraction potential in time interval , , are the production and attraction elasticity coefficients respectively;
[0048] Integrate the predicted OD flows of all nodes , and consider the changes in the time dimension to obtain the traffic flow OD demand distribution matrix .
[0049] The S4 is specifically: converting the generated simulation configuration element set into the required file of the traffic simulation platform, executing the traffic simulation platform simulation to verify the executability and outputting simulation indicators, the simulation indicators including waiting time, travel time, queue length and emission / fuel.
[0050] The method further comprises: S5, generating a reasonable analysis of traffic OD for a real road network scene, comparing the success rate of simulation scene generation by different methods, and verifying the effectiveness of the simulation scene generation result based on the average scene generation time and the execution success rate of the scene when the lightweight student model is inferred.
[0051] Compared with the prior art, the present application has the following beneficial effects:
[0052] (1) Improve the degree of automation: through the semantic driving method based on the large language model, the present application can automatically generate traffic simulation scenes, significantly reduce manual intervention, reduce manual configuration errors and time cost, and improve the generation efficiency and accuracy of the simulation scene.
[0053] (2) Improve the generation accuracy: the present application combines retrieval-enhanced generation mechanism (RAG) with model context protocol (MCP) to quickly retrieve relevant tool descriptions and accurately call MCP tools, greatly improving the success rate of scene generation.
[0054] (3) Reduce inference cost: the present application uses a proxy distillation training method based on a lightweight student model to effectively reduce computational complexity and improve inference efficiency. Through the distillation mechanism, and combined with the first step of the teacher model thinking chain reasoning as a prefix, the student model maintains high efficiency while inheriting the accurate behavior sequence of the teacher model, thereby improving the inference speed and reducing the consumption of computing resources.
[0055] (4) Generate reasonable OD traffic: combined with the inference ability of the traffic knowledge base and the large language model, the present application can accurately capture the actual travel rules and traffic flow patterns, and flexibly handle dynamic factors such as peak and non-peak traffic flow fluctuations, weather changes and unexpected events, to generate as realistic simulation scenes as possible.
[0056] (5) Enhance the controllability and structural degree of the generation process: the present application uses a multi-step reasoning generation process to gradually determine and call the corresponding tools in the tool knowledge base, generating structured simulation configurations composed of multiple simulation configuration elements in sequence, effectively ensuring the compliance, logical consistency and simulation executability of the generated content, avoiding the problems of multiple iterations and low efficiency caused by one-time generation and post-correction mode. BRIEF DESCRIPTION OF DRAWINGS
[0057] Figure 1 is a method flowchart of the present application;
[0058] Figure 2 is a natural language driven traffic simulation scene generation process schematic diagram of the present application;
[0059] Figure 3 Traffic flow trend chart of a city in an embodiment;
[0060] Figure 4 Waiting time analysis chart of simulation results of a city in an embodiment;
[0061] Figure 5 Travel distribution analysis chart of simulation results of a city in an embodiment. DETAILED DESCRIPTION
[0062] The present application will be described in detail below with reference to the accompanying drawings and specific embodiments. The present embodiment is implemented on the premise of the technical solution of the present application, and detailed implementation and specific operation processes are given, but the protection scope of the present application is not limited to the following embodiments.
[0063] To solve the problems of low automation, complex configuration, high computing cost and the like of the existing traffic simulation scene generation method, the present embodiment provides a semantic-driven traffic simulation scene generation method based on a large language model. The method combines the RAG-MCP mechanism to construct an MCP tool knowledge base, so that the LLM can accurately call related tools to realize efficient automatic generation of simulation scenes. To reduce the computing cost of scene generation, a proxy distillation mechanism is introduced to train a lightweight student model based on the interactive trajectory generated by the teacher model, and low-cost semantic-driven scene generation is realized through distillation knowledge transfer. To ensure the authenticity of the generated scene, the importance of the LLM and the traffic knowledge base reasoning node is used to generate as authentic OD flow as possible. The present embodiment has been experimentally verified in an actual urban traffic network, and the proposed method has been compared with a representative method. The results show that the present application significantly reduces the reasoning cost while improving the automation and accuracy of scene generation and enhances the authenticity of the simulation scene, thereby showing obvious advantages in complex traffic simulation scene generation.
[0064] Specifically, the method flow is as shown in Figure 1 The generation process is as shown in Figure 2 and specifically includes the following steps:
[0065] S1, receiving a traffic simulation scene natural language description input by a user.
[0066] The traffic simulation scene natural language description input by the user includes but is not limited to: traffic scene type, region name or geographic coordinates, time condition (peak / non-peak / time period), weather factor (sunny / rainy / snowy, etc.), road grade and signal control mode, travel demand characteristics (passenger flow / vehicle flow, bus priority, etc.), special events (accident / construction / regulation), and the like.
[0067] S2, combined with the search enhancement generation mechanism (RAG) and the model context protocol (MCP), constructs a tool knowledge base, and vectorizes the user input to obtain input semantic encoding, calculates the similarity of the input semantic encoding and each tool description in the tool knowledge base, retrieves a plurality of related tool descriptions, and combines the user input to obtain an extended input.
[0068] In this embodiment, the tool knowledge base Specifically includes tool chain description (MCP template) and SUMO official document fragments, such as road type and priority definition, signal timing template, etc. The text embedding model used in vectorization coding is Acge-Text-Embedding.
[0069] S2 specifically includes the following steps:
[0070] S21, using RAG-MCP to construct a tool knowledge base , store the function, parameter, example, MCP template and executable interface description of the tool, realize semantic enhancement and efficient tool retrieval.
[0071] S22, the user input and each tool description in the tool knowledge base , mapped to vector representation by the text embedding model , respectively obtaining input semantic encoding and tool description vector:
[0072] ,
[0073] Among them, is the input semantic encoding, is the tool description corresponding tool description vector.
[0074] S23, calculate the cosine similarity between the input semantic encoding and each tool description vector in the tool knowledge base:
[0075] ,
[0076] According to the cosine similarity , the tool knowledge base is sorted and the top most relevant tools are selected, denoted as :
[0077] ,
[0078] Among them, indicates taking the tool knowledge base according to the cosine similarity top results.
[0079] S24, splicing the tool description of the top most relevant tools with the original user input to form an extended input .
[0080] S3, calling a large language model (LLM) to perform multi-step reasoning on the extended input, determine the tools required in the tool knowledge base, and generate structured simulation configuration elements using the determined tools; wherein the large language model is trained based on a distillation learning method, and the teacher model first-step thought chain reasoning is introduced as a prefix in the distillation process.
[0081] In this embodiment, the simulation configuration elements to be generated include but are not limited to: road network topology, regional mapping and functional annotation, traffic signal control scheme, vehicle type and behavior rule, event / weather influence parameter and traffic flow OD demand distribution, wherein the traffic signal control scheme includes timing and phase.
[0082] The large language model performs multi-step reasoning in stages to generate a simulation configuration composed of simulation configuration elements generated in sequence , such as existing road networks to generate traffic lights, so the road network related configuration elements must be generated in the previous stage before the traffic light related configuration elements can be generated in the next step. The generation process of the t-th stage simulation configuration element includes the following steps:
[0083] S31, inputting the extended input and the tool knowledge base into the large language model, and combining the retrieval results of step S2 to determine the tool set to be executed for this stage simulation configuration element generation :
[0084] ,
[0085] wherein, denotes the large language model, denotes the set of the top most relevant tools retrieved in step S2; The tools selected by the large language model must be in the tool set selected in step S2 to narrow the selection range of the large language model and reduce the computational complexity.
[0086] S32, based on the previously generated elements , the current knowledge base and the selected tool set , generate the first simulation configuration element of the first stage :
[0087] ,
[0088] wherein, the knowledge base of the current call, when the simulation configuration element generated in the current stage is the traffic flow OD demand distribution, take the traffic knowledge base , when the simulation configuration element generated in the current stage is other than the traffic flow OD demand distribution, take the tool knowledge base , denotes a structured simulation configuration generation function.
[0089] Repeat the above steps S31 and S32 until a complete set of simulation configuration elements is formed.
[0090] That is, in the present embodiment, in addition to the generation of the traffic flow OD demand distribution relying on the large language model through the calling of the traffic knowledge base for additional generation, the rest of the simulation configuration elements are all directly generated by determining the called tools.
[0091] In a preferred embodiment, the process of calling the corresponding tool to generate the traffic flow OD demand distribution in the simulation configuration element includes the following steps:
[0092] Step 1) Based on the place name and the range radius in the user input, obtain the bounding box , i.e. the latitude and longitude of the geographical range, and extract the administrative division .
[0093] Step 2) Download network data from an external road network source (OpenStreetMap or equivalent road network source) and convert it to a SUMO network , extract the node set and edge set .
[0094] Step 3) Map the roads in the road network to the administrative division to obtain , extract the functional attributes of each node in each partition (such as residential / commercial / industrial / public facilities, etc.).
[0095] Step 4) Use the large language model LLM and the traffic knowledge base to infer the node potential for each pair of zones , which includes the origin potential and attraction potential :
[0096] ,
[0097] wherein, denotes the type of the origin node, denotes the type of the destination node, is the adjacency matrix of the road network, representing its topological structure and hierarchy information.
[0098] Step 5) Convert the node potential and inter-node impedance in the time period to the predicted OD flow between nodes by the gravity model: to :
[0099] ,
[0100] wherein, denotes the predicted OD flow from node to node in the time interval , is the origin potential in the time interval , is the attraction potential in the time interval , is the impedance function (such as the distance, time or cost decay function), is the impedance between nodes i and j , , are the production and attraction elasticity coefficients, respectively. In an embodiment, , is the decay parameter of the impedance function, which can be obtained by fitting or least squares optimization calibration method (such as logarithmic linear regression) from the existing observed OD data and inter-node cost data; in this embodiment, the gravity model adopts the classical form.
[0101] Step 6) Integrate the predicted OD flows of all nodes and consider the changes in the time dimension to obtain the traffic flow OD demand distribution matrix .
[0102] The training of LLM on large-scale high-quality data enables it to have certain emergent ability and naturally capture some specific traffic patterns. Combined with the traffic knowledge base This model can effectively infer the traffic flow intensity between different functional zones and take into account changes over time, such as the difference between peak and off-peak hours, thereby generating an OD matrix that varies over time. .
[0103] In this embodiment, the proxy distillation loss function of the large language model is constructed by combining the cross-entropy loss of the large language model's inference response and actions with the behavior regularization term, so as to constrain the student model to select executable and reasonable action sequences and complete the model training.
[0104] Its training process includes the following steps:
[0105] ① Facilitator Model Given extended input With agent instructions The following interacts with the toolchain / simulation environment to generate teacher trajectories:
[0106] ,
[0107] in, Indicating the first position in the trajectory Inference / natural language response at each sampling point Indicating the first position in the trajectory Action / tool call for each sampling point Indicating the first position in the trajectory Tools or environmental observations at each sampling point Represents the generated trajectory Length, Given extended input With agent instructions Teacher Model The output of the model is as follows: Agent instructions refer to commands or operations that an agent performs to execute specific tasks when interacting with the simulation environment or toolchain; they are typically used to guide the agent's behavior and reasoning processes. The responses generated by the guiding model include: Actions, Reasoning, and Observations.
[0108] ② In the distillation process, the thought chain reasoning from the first step of the teacher model is introduced as a prefix to improve distillation stability and update the generation trajectory of the teacher model:
[0109] ,
[0110] in, This represents the first step of the teacher model's thought process reasoning. It serves as a prompt to guide the teacher in generating the initial inference steps of the model. Given extended input With tips Teacher Model The output, Indicating integration The first step of reasoning for the subsequent intelligent agent. Given extended input With agent instructions Next, integration Post-Teacher Model The output.
[0111] ③ Training lightweight student models By focusing on teacher models Behavioral sequences instead of directly optimizing observations Knowledge transfer is achieved by minimizing the following distillation losses:
[0112] ,
[0113] in, This represents the probability that the student model generates the current reasoning and action given all previous reasoning, actions, and observations. , indicating the result of previous reasoning; It is a training dataset of teacher trajectories containing various tasks; Describe the process by which the teacher model generates a complete interaction trajectory under the prompting of the agent; For the parameters of the student model; Let be the expected function. Indicates in Obey the training dataset Under the distribution, for Seeking expectations.
[0114] S4 converts the generated simulation configuration elements into configuration files that can be directly loaded into the traffic simulation platform, and performs simulation verification in the traffic simulation platform (such as the SUMO system).
[0115] S4 specifically refers to: generating the set of simulation configuration elements. Convert the data into the files required by the traffic simulation platform, such as net.xml, route.xml, and add.xml files. Execute the traffic simulation platform to verify executability and output simulation metrics (including waiting time, travel time, queue length, and emissions / fuel consumption). The output can also be converted to the configuration formats of platforms such as Aimsun and VISSIM to achieve cross-platform compatibility.
[0116] Specifically, the generated traffic flow OD demand distribution can be assigned to the corresponding origin and destination edges. And generate an edge-to-edge OD list. Then, Convert to DataFrame and generate SUMO's trips.xml, then generate route file through SUMO duarouter.
[0117] S5, the rationality of traffic OD generated by the real road network scene is analyzed, the success rate of different methods for generating simulation scene is compared, and the average scene generation time and the execution success rate of the scene are based on the lightweight student model reasoning, and the effectiveness of the simulation scene generation result is verified.
[0118] This embodiment adopts SUMO micro-traffic simulation software for verification, and the experimental equipment is a workstation equipped with NVIDIA RTX4090 GPU, 64 GB memory and Intel Core i9-14900K CPU, and the operating system is Windows 11. The user natural language input is processed through the Ollama library, and the Qwen3 series model (Qwen3:8b and Qwen3:0.6b) is called for reasoning and semantic analysis. ChatSUMO is selected as the baseline method, and the scene generated by the manual command line (CLI) is used as another control.
[0119] The scene generation time and success rate in the application are compared by comparing the average time of generating scenes by different methods under the same scale. 100 urban scenes are generated within a radius of 3km, and the complete pipeline time from natural language input to executable SUMO configuration file is measured, and the results are shown in Table 1. The CLI method takes more than 15 minutes on average, and it is difficult to handle complex semantics or diversified scene requirements; ChatSUMO generates faster, but the success rate is limited, mainly due to the lack of precise tool chain calling ability; the method based on Qwen3:8b and combined with RAG-MCP module in the application has an average generation time of 135 seconds, while maintaining the semantic integrity; the distilled lightweight Qwen3:0.6b model further reduces the reasoning overhead to 91 seconds, and shows higher practicability in resource-limited environment.
[0120] Table 1 Comparison of average generation time and success rate of each method
[0121]
[0122] To verify the reasonableness of the generated OD flow, the generated OD flow matrix is visualized. The high flow area in the central area (3km radius) of A city is concentrated, and the commuter corridor is distributed along the main trunk road, showing a pattern of high flow in the core area and gradual attenuation in the periphery, which is consistent with the typical urban commuting mode. The central area (3km radius) of B city presents a typical urban mode of "core concentration-corridor extension-peripheral sparseness", with high flow in the main commuting core area and gradually decreasing flow in the periphery, which is consistent with the urban functional zoning and main commuting corridor. The above results show that the OD distribution generated by the invention is reasonable and interpretable in terms of spatial structure and flow trend, and can reflect the actual urban traffic rules.
[0123] Further verification of the generated scene is carried out through SUMO simulation, and the simulation report is displayed. Figure 3 The traffic flow trend is displayed, and the large model output under this scene is as follows:
[0124] Total number of vehicles: 2948.
[0125] The traffic flow data reflects the following characteristics:
[0126] 1. Traffic stability: The maximum flow (58 vehicles / minute) is only about 14% higher than the average flow (50.8 vehicles / minute), indicating that the overall traffic flow fluctuates little and there is no obvious peak.
[0127] 2. Lack of peak period: The peak period field is empty, which may indicate that the data is not recorded or a clear peak period is not identified, and further verification of data integrity or analysis of traffic distribution over a longer period of time is needed.
[0128] 3. Potential trends: If the data coverage is short (e.g., a single day or a single week), it may be necessary to observe periodic fluctuations (e.g., differences between weekdays and weekends) and analyze them in combination with longer periods of time.
[0129] Recommendation: Check if the data collection range covers the entire time period, or supplement the definition of peak period to clarify the traffic characteristics.
[0130] Figure 4 and Figure 5 The vehicle waiting time and travel time distribution analysis results are displayed respectively, reflecting the overall traffic efficiency and local congestion, and the corresponding large model output is as follows:
[0131] ① Output of waiting time distribution:
[0132] Average waiting time: 57.3.
[0133] This traffic flow data reflects the following congestion and efficiency problems:
[0134] 1. Overall efficiency is acceptable: The average waiting time (57.3 seconds) is at a moderate level, indicating that most vehicles can pass smoothly.
[0135] 2. Local severe congestion:
[0136] The maximum waiting time is 712 seconds (11.7 minutes), which is much higher than the threshold of 5 minutes considered necessary to pass, indicating an extreme congestion situation.
[0137] 49 vehicles have a waiting time of more than 5 minutes, which may indicate bottlenecks in certain sections or intersections, or may be caused by improper signal timing, lane design defects, or unexpected events (such as accidents).
[0138] 3. Congestion risk warning:
[0139] Extreme waiting times may cause driver fatigue, delays, and even safety hazards, and the root cause of congestion needs further investigation (such as signal timing, road capacity, traffic flow distribution, etc.).
[0140] If the data covers the peak period, signal control optimization or road capacity increase may be needed to alleviate local congestion.
[0141] Recommendation: Further analysis combined with traffic flow data is recommended to identify the root cause of congestion and optimize signal timing or adjust lane design to reduce extreme waiting times.
[0142] ② Output of travel time distribution:
[0143] The average travel time is 363.7 seconds.
[0144] This traffic flow data reflects the following traffic operation efficiency and stability characteristics:
[0145] 1. Overall efficiency is moderate: The average travel time (363.7 seconds, about 6 minutes) is at a moderate level, indicating that the efficiency of most vehicles is at a moderate level, but has not yet reached the effective operation standard (usually the effective travel time is less than 300 seconds).
[0146] 2. Significant volatility:
[0147] The standard deviation (377.2 seconds) indicates that the travel time distribution is extremely uneven, and some vehicles may experience extremely long travel times due to congestion, accidents, or signals.
[0148] The 95th percentile (983.3 seconds, about 16.4 minutes) is much higher than the average level, indicating that about 5% of vehicles experience severe delays, which may be related to sudden congestion, accidents, construction, or bottlenecks.
[0149] 3. Unstable Trend: High standard deviation and long tail distribution indicate significant instability in the traffic system, which requires further investigation of the root causes (e.g., signal timing, lane design, or network capacity).
[0150] Recommendation: Prioritize signal timing or lane design adjustments in conjunction with traffic flow and waiting time data to reduce travel time fluctuations and improve overall traffic efficiency.
[0151] Here are the large model output results for emissions and fuel analysis:
[0152] Total CO2 emissions: 4986.30 tons;
[0153] Total fuel consumption: 1616.47 liters;
[0154] Total CO emissions: 54.81 tons;
[0155] Total electricity consumption: 0.00 kWh;
[0156] Total PMx emissions: 0.42 tons.
[0157] Emissions data characteristics and environmental assessment:
[0158] 1. CO2 emissions (4986.30 tons):
[0159] If the data is the total emissions for a certain region or a specific period (e.g., monthly), it needs to be judged as reasonable based on the traffic scale (such as the number of vehicles and mileage). For example, if the average traffic flow of the region is large, it may be within the normal level; if it is a small region, it may exceed the environmental expectations.
[0160] Issue: CO2 is the main greenhouse gas, and if it does not meet the national or international emission reduction targets (such as the Paris Agreement), optimization is needed.
[0161] 2. CO emissions (54.81 tons):
[0162] CO is a toxic gas harmful to health. The current value needs to be compared with the local emission standard, and if it exceeds the standard, it means that the exhaust purification system (such as the three-way catalyst) may have defects, or the vehicle is aging.
[0163] 3. PMx emissions (0.42 tons):
[0164] Low PMx (particulate matter) emissions indicate potential clean fuel (such as low-sulfur diesel) or exhaust treatment technology (such as diesel particulate filters). However, it needs to be noted that if the vehicle is mainly diesel, PM emissions may still be high, which needs to be further verified.
[0165] 4. Fuel consumption (1616.47 liters):
[0166] Fuel consumption is closely related to CO2 emissions. If the vehicle is primarily a gasoline car and fuel efficiency is low (such as frequent start-stop, congestion), fuel economy needs to be improved to reduce emissions.
[0167] 5. Electricity consumption (0 kWh):
[0168] Zero electricity consumption indicates that there are no electric vehicles in the current transportation system. If the goal is a low-carbon transition, new energy vehicles (such as electric buses and shared electric vehicles) need to be promoted faster.
[0169] Environmental expectations and problems
[0170] 1. Compliance:
[0171] If the area is industrial or high-density urban, emissions may be at a medium level; however, if it is an ecological protection zone or a low-carbon demonstration area, it may exceed environmental protection expectations.
[0172] Key issues:
[0173] CO emissions do not meet standards (for example, the CO limit in China's "Comprehensive Emission Standard of Air Pollutants" is 200 mg / m 3 ).
[0174] Electricity consumption is zero, and there is a lack of motivation for new energy transformation.
[0175] 2. Potential risks:
[0176] High CO2 and CO emissions may exacerbate air pollution and climate change, which need to be controlled first.
[0177] PMx emissions are low, but further verification is needed to determine whether it is caused by detection methods or vehicle types (such as a high proportion of light vehicles).
[0178] Improvement suggestions
[0179] 1. Promote new energy vehicles:
[0180] Promote alternative fuel vehicles such as electric cars and hydrogen cars to reduce CO2 and CO emissions.
[0181] Provide subsidies or policy incentives (such as charging pile construction, purchase discounts).
[0182] 2. Optimize traffic management:
[0183] Reduce idling and frequent start-stop through intelligent traffic lights, congestion charges, etc., to reduce CO and fuel consumption.
[0184] Encourage public transportation, shared rides, and reduce private car usage.
[0185] 3. Strengthen emissions supervision:
[0186] Regularly test vehicle emissions and eliminate high-pollution vehicles.
[0187] Promote clean fuels (such as low-sulfur diesel, biofuels) and exhaust purification technologies (such as particulate traps).
[0188] 4. Data supplement and analysis:
[0189] Clearly define the time range of data (such as year / month) and analyze according to parameters such as traffic flow and vehicle type.
[0190] Compare regional / national emission standards and set targeted emission reduction goals.
[0191] Summary
[0192] Current data shows that the transportation system is still dominated by fuel vehicles, with high CO2 and CO emissions and significant environmental impact. To reduce environmental impact, new energy transformation, transportation optimization, and emissions supervision should be implemented. If the goal is to achieve air quality standards, the above measures should be prioritized, and the improvement effect should be monitored regularly.
[0193] The experimental results show that the present application can efficiently generate multi-dimensional traffic simulation scenes, and the scenes are reasonable and consistent with actual traffic dynamics, providing a reliable foundation for large-scale automated simulation and optimization.
[0194] To verify the contribution of the RAG-MCP module to scene generation, an ablation experiment was conducted. The RAG-MCP module was removed, and the remaining components remained unchanged. The results are shown in Table 2. After removing the RAG-MCP module, the tool selection success rate decreased significantly; with the increase in the number of candidate tools, the success rate further decreased, indicating that this module is crucial for handling complex tasks and maintaining the consistency of the generated scene; the complete model is superior to the model without RAG-MCP in all configurations, for example, 0.92 vs. 0.72 when there are 50 tools, and 0.87 vs. 0.53 when there are 100 tools.
[0195] Table 2 Ablation study results of tool selection success rate under different tool quantities
[0196]
[0197] In conclusion, the application relates to a semantic driving traffic simulation scene generation method based on a large language model, which can automatically generate a simulation scene conforming to actual travel rules by combining a large language model and a traffic knowledge base, significantly improving the automation degree, accuracy and efficiency of the simulation process, reducing manual intervention, and effectively improving the operability and application value of the traffic simulation result.
[0198] The preferred embodiments of the application are described in detail above. It should be understood that those of ordinary skill in the art can make many modifications and changes without requiring creative efforts based on the concept of the application. Therefore, any technical solutions obtained by logical analysis, reasoning or limited experiments based on the prior art according to the concept of the application should be within the protection scope of the claims.
Claims
1. A semantically driven traffic simulation scene generation method based on a large language model, characterized in that, Includes the following steps: S1 receives natural language descriptions of traffic simulation scenarios input by the user; S2, construct a tool knowledge base, and vectorize and encode the user input to obtain the input semantic code. Calculate the similarity between the input semantic code and the descriptions of each tool in the tool knowledge base, retrieve multiple related tool descriptions, and merge them with the user input to obtain the extended input; S3, invoke the large language model to perform multi-step reasoning on the extended input, determine the tools to be invoked in the tool knowledge base, and use the determined tools to generate structured simulation configuration elements; wherein, the large language model is trained based on distillation learning, and the thought chain reasoning of the first step of the teacher model is introduced as a prefix in the distillation process; S4 converts the generated simulation configuration elements into configuration files that can be directly loaded into the traffic simulation platform, and performs simulation verification in the traffic simulation platform; Specifically, S3 involves the large language model performing multi-stage reasoning to generate a language model that... A series of sequentially generated simulation configuration elements The simulation configuration consists of elements for stage t, where the simulation configuration elements for stage t are... The generation process includes the following steps: S31 will expand the input and tools knowledge base Input the large language model and, in conjunction with the search results from step S2, determine the toolset to be executed in generating the simulation configuration elements for this stage. : , in, Representing a large language model, This indicates the previous steps retrieved in step S2. A set consisting of the most relevant tools; S32, Based on the elements already generated before the configuration element generation in this simulation. Current knowledge base and the chosen toolset , generate the first Simulation configuration elements of the stage : , in, This indicates the knowledge base currently being invoked. When the simulation configuration element generated in this stage is the traffic flow OD demand distribution, When generating simulation configuration elements other than traffic flow OD demand distribution from the traffic knowledge base in this stage, Access tool knowledge base This represents a structured simulation configuration generation function; Repeat steps S31 and S32 above until a complete set of simulation configuration elements is formed. ; The process of generating traffic flow OD demand distribution in the process of generating structured simulation configuration elements using defined tools includes the following steps: Based on the place name input by the user With range radius Get bounding box That is, the geographical range of latitude and longitude, and extract the administrative divisions. ; Download network data from external road network sources And convert to a SUMO network Extract node set With edge set ; Mapping roads in the road network to administrative districts yields... Extract each node from each partition Functional attributes ; LLM (Large Language Model) and Traffic Knowledge Base For each pair of areas Inference node potential, the node potential including the starting point potential and attract potential : , in, Indicates the type of the starting node. Indicates the type of the destination node. This is the adjacency matrix of the road network, representing its topological structure and hierarchical information; Time period The node potential and inter-node impedance Convert to node arrive Predicted OD flow: , in, Indicates the time interval Inside, from the node To the node Predicted OD flow, It is the impedance function. Time interval The potential within, Time interval The potential for attraction within, , These are the production and attraction elasticity coefficients, respectively. Combined prediction of OD traffic from all nodes Considering the changes over time, the traffic flow OD demand distribution matrix is obtained. .
2. The semantic-driven traffic simulation scene generation method based on a large language model according to claim 1, characterized in that, The natural language description of the traffic simulation scenario input by the user includes: traffic scenario type, area name or geographical coordinates, time conditions, weather factors, road grade and signal control method, travel demand characteristics and special events. The time conditions include peak, off-peak or time period, and the special events include accidents, construction or traffic control.
3. The semantic-driven traffic simulation scene generation method based on a large language model according to claim 1, characterized in that, The simulation configuration elements include road network topology, area mapping and function labeling, traffic signal control scheme, vehicle type and behavior rules, event / weather impact parameters and traffic flow OD demand distribution, wherein the traffic signal control scheme includes timing and phase.
4. The semantic-driven traffic simulation scene generation method based on a large language model according to claim 1, characterized in that, S2 specifically includes the following steps: S21. Utilize RAG-MCP to build a tool knowledge base, storing tool functions, parameters, examples, MCP templates, and executable interface descriptions to achieve semantic enhancement and efficient tool retrieval; S22, the user input and each tool description in the tool knowledge base are mapped into vector representations through a text embedding model, resulting in the input semantic encoding and the tool description vector respectively; S23, calculate the cosine similarity between the input semantic code and the description vectors of each tool in the tool knowledge base, sort the tool knowledge base according to the cosine similarity, and select the top... The most relevant tools; S24, will be forward The tool descriptions of the most relevant tools are concatenated with the original user input to form an expanded input.
5. The semantic-driven traffic simulation scene generation method based on a large language model according to claim 1, characterized in that, The proxy distillation loss function of the large language model is constructed by combining the cross-entropy loss of the large language model's inference response and action with the behavior regularization term, so as to constrain the student model to select executable and reasonable action sequences and complete the model training.
6. The semantic-driven traffic simulation scene generation method based on a large language model according to claim 1, characterized in that, The training process of the large language model includes the following steps: Facilitator Model Given extended input With agent instructions The following interacts with the toolchain / simulation environment to generate teacher trajectories: , in, Indicating the first position in the trajectory Reasoning / natural language response at each sampling point Indicating the first position in the trajectory Action / tool call for each sampling point Indicating the first position in the trajectory Tools or environmental observations at each sampling point Represents the generated trajectory Length, Given extended input With agent instructions Teacher Model The output; To improve distillation stability, the thought chain reasoning from the first step of the teacher model is introduced as a prefix during the distillation process, thus updating the generation trajectory of the teacher model: , in, This represents the first step of the teacher model's thought process reasoning. It serves as a prompt to guide the teacher in generating the initial inference steps of the model. Given extended input With tips Teacher Model The output, Indicating integration The first step of reasoning for the subsequent intelligent agent. Given extended input With agent instructions Next, integration Post-Teacher Model The output; Training lightweight student models By focusing on teacher models Behavioral sequences instead of directly optimizing observations Knowledge transfer is achieved by minimizing the following distillation losses: , in, This represents the probability that the student model generates the current reasoning and action given all previous reasoning, actions, and observations. , indicating the result of previous reasoning; It is a training dataset of teacher trajectories containing various tasks; Describe the process by which the teacher model generates a complete interaction trajectory under the prompting of the agent; For the parameters of the student model; Let be the expected function. Indicates in Obey the training dataset Under the distribution, for Seeking expectations.
7. The semantic-driven traffic simulation scene generation method based on a large language model according to claim 1, characterized in that, Specifically, S4 involves converting the generated set of simulation configuration elements into files required by the traffic simulation platform, executing the traffic simulation platform to verify executability, and outputting simulation metrics, including waiting time, travel time, queue length, and emissions / fuel.
8. The semantic-driven traffic simulation scene generation method based on a large language model according to claim 1, characterized in that, The method further includes: S5, analyzing the rationality of generating traffic OD in real road network scenarios, comparing the success rates of generating simulation scenarios using different methods, and verifying the effectiveness of simulation scenario generation results by comparing the average scenario generation time and the scenario execution success rate when inferring based on a lightweight student model.
Citation Information
Patent Citations
Automatic driving test scene generation framework and generation method
CN119598726A
Method and system for identifying and describing potential safety hazards of rail transit engineering construction
CN120913118A
Knowledge distillation-based compression method for pre-trained language model, and platform
WO2021248868A1