Semantic-driven traffic simulation scene generation method based on large language model

By combining a large language model with a knowledge base, the automatic conversion from natural language input to traffic simulation configuration files is achieved, which solves the problem of low automation in existing traffic simulation systems, improves the accuracy and efficiency of simulation results, and can generate simulation scenarios that conform to actual travel patterns.

CN121328352AActive Publication Date: 2026-01-13TONGJI UNIV

Patent Information

Application Number
CN202511882215.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-15
Publication Date
2026-01-13
Estimated Expiration
2045-12-15

AI Technical Summary

Technical Problem

Existing traffic simulation systems suffer from low automation, poor computational efficiency, inaccurate simulation results, difficulty in handling complex traffic scenarios and dynamic changes, and lack of flexible response to user needs.

Method used

By combining a large language model with a knowledge base, and utilizing the RAG-MCP mechanism and surrogate distillation training method, the automatic conversion of natural language input into simulation configuration files is achieved, generating structured simulation configuration elements, including road network topology, traffic signal control, and OD demand distribution.

Benefits of technology

It improves the automation and generation efficiency of traffic simulation scenarios, enhances the accuracy and controllability of simulation results, and can flexibly handle dynamic changes to generate simulation scenarios that conform to actual travel patterns.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121328352A_ABST
    Figure CN121328352A_ABST
Patent Text Reader

Abstract

The invention relates to a semantic-driven traffic simulation scene generation method based on a large language model. The method comprises the following steps: receiving traffic simulation scene natural language description input by a user; constructing a tool knowledge base, performing retrieval in the tool knowledge base based on user input, and combining a retrieval result with the user input to obtain extended input; calling the large language model to carry out multi-step reasoning on the extended input, determining a tool needing to be called in a tool knowledge base, and generating a structured simulation configuration element by utilizing the determined tool; and converting the generated simulation configuration elements into a configuration file which can be directly loaded to a traffic simulation platform, and executing simulation verification in the traffic simulation platform. Compared with the prior art, natural language input can be automatically converted into a structured and executable traffic simulation configuration file under the condition that manual intervention is not needed, and high efficiency and intelligence of scene construction are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of traffic simulation technology, and in particular to a semantically driven traffic simulation scene generation method based on a large language model. Background Technology

[0002] With the increasing complexity and scale of urban transportation networks, traditional traffic simulation methods face significant challenges. Existing traffic simulation systems typically rely on manual input and configuration of elements such as traffic networks, travel demand, and traffic signals. This is not only time-consuming and resource-intensive but also makes it difficult to guarantee the accuracy and flexibility of simulation results. With the advancement of artificial intelligence technology, especially the development of Large Language Models (LLMs), data-driven automated traffic simulation methods have gradually become a research hotspot.

[0003] Currently, while some AI-based traffic simulation methods exist, most still rely on rule engines or fixed model structures, lacking the ability to intelligently reason about complex traffic scenarios and dynamic changes. Furthermore, existing methods typically require substantial computational resources when processing large-scale traffic data, and struggle to balance efficiency and accuracy. Existing traffic simulation systems also suffer from insensitivity to user needs and a lack of integration with real-time data, resulting in simulation scenarios that fail to accurately reflect real-world traffic flow and emergencies.

[0004] Chinese patent CN119598726A discloses a framework and method for generating autonomous driving test scenarios. It employs the interaction of a multimodal large language model based on cue engineering and traffic simulation tools to generate node and edge files, integrate road network files and vehicle models, construct a traffic simulation mechanism, and generate customized autonomous driving test scenarios. While this method utilizes a multimodal large language model and cue word engineering to convert natural language descriptions into simulation configuration files, its core approach remains at the level of template-based formatted output and post-processing error correction. This results in the following shortcomings: a lack of deep semantic understanding and structured parsing mechanisms for natural language input; and the reliance on cue word engineering and performance evaluators primarily on generating code format files from preset templates and performing iterative path corrections. This leads to deficiencies in semantic understanding accuracy, the structured nature of scenario generation, the controllability of the reasoning process, and the reliability of the generated results, making it difficult to achieve high-precision, highly automated, and semantically driven traffic simulation scenario generation. Summary of the Invention

[0005] The purpose of this invention is to provide a semantically driven traffic simulation scenario generation method based on a large language model. By combining natural language input with a knowledge base, and utilizing the emergent capabilities of the large language model and traffic flow modeling technology, a traffic simulation scenario that conforms to actual travel patterns can be automatically generated. This method can effectively solve the problems of low automation, poor computational efficiency, and inaccurate simulation results in existing technologies.

[0006] The objective of this invention can be achieved through the following technical solutions: A semantically driven traffic simulation scene generation method based on a large language model 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.

[0007] 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.

[0008] The simulation configuration elements include road network topology, regional mapping and functional labeling, traffic signal control scheme, vehicle type and behavior rules, event / weather impact parameters and traffic flow OD (Origin-Destination) demand distribution, wherein the traffic signal control scheme includes timing and phase.

[0009] S2 specifically includes the following steps: S21 utilizes RAG-MCP (Retrieval-Augmented Generation - Model Context Protocol) to build a tool knowledge base, storing the tool's functions, parameters, examples, MCP (Model Context Protocol) 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.

[0010] 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.

[0011] 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. This indicates 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.

[0012] 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 collection 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. .

[0013] 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 it into a SUMO (Simulation of Urban Mobility, an open-source microscopic traffic simulation software) 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. .

[0014] 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.

[0015] The method further includes: S5, analyzing the rationality of generating traffic OD in real road network scenarios, comparing the success rates of different methods in generating simulation scenarios, 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.

[0016] Compared with the prior art, the present invention has the following beneficial effects: (1) Improve automation: By using a semantic-driven method based on a large language model, this invention can automatically generate traffic simulation scenarios, significantly reduce manual intervention, reduce manual configuration errors and time costs, and improve the generation efficiency and accuracy of simulation scenarios.

[0017] (2) Improve generation accuracy: By combining the Retrieval-Augmented Generation (RAG) mechanism with the Model Context Protocol (MCP), this invention can quickly retrieve relevant tool descriptions and accurately call MCP tools, which greatly improves the success rate of scene generation.

[0018] (3) Reduced reasoning cost: The agent distillation training method based on the lightweight student model in this invention can effectively reduce computational complexity and improve reasoning efficiency. Through the distillation mechanism, and combined with the first step of the teacher model's thought chain reasoning as a prefix, the student model inherits the teacher model's precise behavioral sequence while maintaining efficient reasoning, thereby improving reasoning speed and reducing the consumption of computational resources.

[0019] (4) Generate reasonable OD flow: Combining the reasoning ability of traffic knowledge base and large language model, this invention can accurately capture actual travel patterns and traffic flow patterns, flexibly handle dynamic change factors, such as traffic flow fluctuations during peak and off-peak hours, weather changes and emergencies, and generate simulation scenarios that are as realistic as possible.

[0020] (5) Enhance the controllability and structuring of the generation process: The present invention adopts a phased and multi-step reasoning generation process, gradually determines and calls the corresponding tools in the tool knowledge base, and generates a structured simulation configuration composed of multiple simulation configuration elements in sequence, which effectively ensures the compliance, logical consistency and simulation executability of the generated content, and avoids the problems of multiple iterations and low efficiency caused by one-time generation and post-error correction mode. Attached Figure Description

[0021] Figure 1 This is a flowchart of the method of the present invention; Figure 2 This is a schematic diagram of the natural language-driven traffic simulation scene generation process of the present invention; Figure 3 This is a traffic flow trend chart for a city in one embodiment; Figure 4 This is a waiting time analysis chart of a simulation result for a certain city in one embodiment; Figure 5 This is a travel distribution analysis diagram of a city based on simulation results in one embodiment. Detailed Implementation

[0022] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. These embodiments are based on the technical solution of the present invention and provide detailed implementation methods and specific operating procedures. However, the scope of protection of the present invention is not limited to the following embodiments.

[0023] To address the issues of low automation, complex configuration, and high computational costs in existing traffic simulation scene generation methods, this embodiment provides a semantic-driven traffic simulation scene generation method based on a large language model. This method combines the RAG-MCP mechanism to construct an MCP tool knowledge base, enabling the LLM (Large Language Model) to accurately call relevant tools and achieve efficient automatic generation of simulation scenes. To reduce the computational cost of scene generation, a proxy distillation mechanism is introduced, allowing a lightweight student model to be trained on the interactive trajectories generated by the teacher model. Knowledge transfer through distillation achieves low-cost semantic-driven scene generation. To ensure the realism of the generated scenes, the importance of inference nodes in the LLM and traffic knowledge base is utilized to generate OD (Original Distance Occurrence) traffic as realistically as possible. This embodiment was experimentally verified in a real urban traffic network, and the proposed method was compared with representative methods. The results show that this invention significantly reduces inference costs and enhances the realism of simulation scenes while improving the automation and accuracy of scene generation, thus demonstrating a clear advantage in generating complex traffic simulation scenes.

[0024] Specifically, the method flow is as follows: Figure 1 As shown, the generation process is illustrated below. Figure 2 As shown, the specific steps include: S1 receives natural language descriptions of traffic simulation scenarios input by the user.

[0025] The natural language description of the traffic simulation scenario input by the user includes, but is not limited to: traffic scenario type, area name or geographical coordinates, time conditions (peak / off-peak / time period), weather factors (sunny / rainy / snowy, etc.), road grade and signal control method, travel demand characteristics (passenger flow / vehicle flow, public transport priority, etc.), special events (accidents / construction / control), and other information.

[0026] S2, combining the Retrieval Enhancement Generation Mechanism (RAG) and Model Context Protocol (MCP), constructs a tool knowledge base, and vectorizes the user input to obtain the input semantic code. The similarity between the input semantic code and the descriptions of each tool in the tool knowledge base is calculated, and multiple related tool descriptions are retrieved and merged with the user input to obtain the extended input.

[0027] In this embodiment, the tool knowledge base Specifically, this includes toolchain descriptions (MCP templates) and snippets from the SUMO official documentation, such as road type and priority definitions, signal timing templates, etc. The vectorized encoding uses Acce-Text-Embedding as the text embedding model.

[0028] S2 specifically includes the following steps: S21, Building a tool knowledge base using RAG-MCP This document describes the functions, parameters, examples, MCP templates, and executable interfaces of storage tools, enabling semantic enhancement and efficient tool retrieval.

[0029] S22, User input and tools knowledge base Each tool description in Through text embedding model The mapping is converted into vector representations, yielding the input semantic encoding and tool description vectors respectively: , in, For input semantic encoding, Tool description The corresponding tool description vector.

[0030] S23, Calculate the input semantic code With the tool description vectors in the tool knowledge base cosine similarity : , Based on the cosine similarity Sort the tool knowledge base and select the top ones. The most relevant tools are denoted as : , in, This indicates that the knowledge base of the tool is retrieved based on cosine similarity. Before sorting One result.

[0031] S24, will be forward The tool descriptions of the most relevant tools are combined with the original user input to form an extended input. .

[0032] S3, invoke the Large Language Model (LLM) 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.

[0033] In this embodiment, the simulation configuration elements to be generated include, but are not limited to: 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.

[0034] The large language model performs multi-stage reasoning to generate... A series of sequentially generated simulation configuration elements The simulation configuration must be based on an existing road network to generate traffic lights. Therefore, 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 stage. Specifically, the simulation configuration elements in stage t... 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 collection consisting of the most relevant tools; The tools constrained in the selection of large speech models must be from the set of tools selected in step S2, in order to narrow down the selection range of large language models and reduce computational complexity.

[0035] 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, Access the traffic knowledge base When generating simulation configuration elements other than traffic flow OD demand distribution in this stage, Access tool knowledge base , This represents a structured simulation configuration generation function.

[0036] Repeat steps S31 and S32 above until a complete set of simulation configuration elements is formed. .

[0037] That is, in this embodiment, except for the generation of traffic flow OD demand distribution which depends on the large language model to generate additional data by calling the traffic knowledge base, all other simulation configuration elements are directly generated by the tools that are called.

[0038] 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: Step 1) Based on the place name in the user input With range radius Get bounding box That is, the geographical range of latitude and longitude, and extract the administrative divisions. .

[0039] Step 2) Download network data from an external road network source (OpenStreetMap or equivalent road network source). And convert to a SUMO network Extract node set With edge set .

[0040] Step 3) Map the roads in the road network to administrative divisions to obtain... Extract each node from each partition Functional attributes (such as residential / commercial / industrial / public facilities, etc.).

[0041] Step 4) Utilizing Large Language Model (LLM) 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. Let be the adjacency matrix of the road network, representing its topological structure and hierarchical information.

[0042] Step 5) Divide the time period The node potential and inter-node impedance Transformed into nodes through a gravity model arrive Predicted OD flow: , in, Indicates the time interval Inside, from the node To the node Predicted OD flow, Time interval The potential within, Time interval The potential for attraction within, It is an impedance function (such as an attenuation function for distance, time, or cost). For nodes i and j The impedance between them , These are the production and attraction elasticity coefficients, respectively. In one embodiment, , The attenuation parameter of the impedance function can be obtained by fitting existing observed OD data and inter-node cost data or by least squares optimization calibration methods (such as log-linear regression); in this embodiment, the gravity model adopts the classical form.

[0043] Step 6) Combine the predicted OD flows of all nodes Considering the changes over time, the traffic flow OD demand distribution matrix is ​​obtained. .

[0044] Training LLM on large-scale, high-quality data endows it with a certain emergent ability, enabling it to naturally capture specific traffic patterns. Combined with a 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. .

[0045] 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.

[0046] Its training process 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 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.

[0047] ② 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: , 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.

[0048] ③ 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. This indicates 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.

[0049] 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).

[0050] S4 specifically refers to: generating a 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.

[0051] 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 a DataFrame and generate SUMO's trips.xml, then generate the route file using SUMO duarouter.

[0052] S5 analyzes the rationality of generating traffic OD in real road network scenarios, compares the success rates of different methods for generating simulation scenarios, and verifies 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.

[0053] This embodiment uses SUMO microscopic traffic simulation software for verification. The experimental equipment is a workstation equipped with an NVIDIA RTX4090 GPU, 64 GB of memory, and an Intel Core i9-14900K CPU, running Windows 11. User natural language input is processed through the Ollam library, and the Qwen3 series models (Qwen3:8b and Qwen3:0.6b) are used for inference and semantic parsing. ChatSUMO is selected as the baseline method, and a scenario generated by manual command line (CLI) is used as another control.

[0054] In this invention, scene generation time and success rate are compared by evaluating the average time of different methods to generate scenes on the same scale. One hundred city scenes were generated within a 3km radius, and the complete pipeline time from natural language input to generating an executable SUMO configuration file was measured. The results are shown in Table 1. The CLI method takes an average of over 15 minutes and struggles to handle complex semantics or diverse scene requirements. ChatSUMO has a faster generation speed but a limited success rate, mainly due to a lack of precise toolchain invocation capabilities. The method in this invention, based on Qwen3:8b and combined with the RAG-MCP module, achieves an average generation time of 135 seconds while maintaining semantic integrity. The lightweight Qwen3:0.6b model obtained through distillation further reduces inference overhead to 91 seconds, demonstrating greater practicality in resource-constrained environments.

[0055] Table 1 Comparison of average generation time and success rate for each method To verify the rationality of the generated OD traffic patterns, the generated OD traffic matrix was visualized. In City Center A (3km radius), high-traffic areas are concentrated, with commuter corridors distributed along major arterial roads, exhibiting a pattern of high traffic in the core area and gradually decreasing traffic in the periphery, consistent with typical urban commuting patterns. City Center B (3km radius) exhibits a typical urban pattern of "concentrated core – extended corridors – sparse periphery," with high traffic in the main commuter core area extending outwards along major roads, and traffic gradually decreasing in the periphery, consistent with urban functional zoning and major commuter corridors. These results demonstrate that the OD distribution generated by this invention is reasonable and interpretable in terms of spatial structure and traffic trends, and can reflect actual urban traffic patterns.

[0056] The generated scenario was further verified using SUMO simulation, and a simulation report was presented. Figure 3 The traffic flow trend is illustrated, and the output of the large model in this scenario is as follows: Total number of vehicles: 2948.

[0057] The traffic flow data reflects the following characteristics: 1. Traffic stability: The maximum flow rate (58 vehicles / minute) is only about 14% higher than the average flow rate (50.8 vehicles / minute), indicating that the overall traffic flow fluctuates little and there are no obvious peak periods.

[0058] 2. Missing Peak Periods: The Peak Period field is empty, which may indicate that no data was recorded or no clear peak period was identified. Further verification of data integrity or analysis of traffic distribution over a longer period is needed.

[0059] 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., the difference between weekdays and weekends) and combine them with analysis over a longer period.

[0060] Recommendation: Check whether the data collection scope covers the entire time period, or supplement the definition of peak hours to clarify traffic characteristics.

[0061] Figure 4 and Figure 5 The analysis results of vehicle waiting time and travel time distribution are presented separately, reflecting overall traffic efficiency and local congestion. The corresponding large model output is as follows: ① Output of waiting time distribution: Average waiting time: 57.3 seconds.

[0062] This traffic flow data reflects the following congestion and efficiency issues: 1. Overall efficiency is acceptable: The average waiting time (57.3 seconds) is at a moderate level, indicating that most vehicles can pass smoothly.

[0063] 2. Severe localized congestion: The maximum waiting time was 712 seconds (11.7 minutes), which is far higher than the threshold that is usually considered to take more than 5 minutes to pass through, indicating that there is extreme congestion.

[0064] The fact that 49 vehicles were waiting for more than 5 minutes could indicate a bottleneck at some road section or intersection, or it could be due to improper traffic light timing, lane design flaws, or an unexpected event such as an accident.

[0065] 3. Congestion Risk Warning: Extreme waiting times can lead to driver fatigue, delays, and even safety hazards. The root causes of congestion need further investigation (such as traffic light timing, road capacity, and traffic flow distribution).

[0066] If the data covers peak hours, it may be necessary to optimize signal control or increase road capacity to alleviate local congestion.

[0067] Recommendation: Conduct further analysis based on traffic flow data to identify the root causes of congestion, and optimize traffic light timings or adjust lane designs to reduce extreme waiting times.

[0068] ② Output of travel time distribution: Average travel time: 363.7 minutes.

[0069] This traffic flow data reflects the following characteristics of traffic operation efficiency and stability: 1. Overall efficiency is moderate: The average trip time (363.7 seconds, about 6 minutes) is at a moderate level, indicating that most vehicles are at a moderate level of efficiency, but have not yet reached the standard for effective operation (usually effective trip time is less than 300 seconds).

[0070] 2. Significant volatility: 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 traffic lights.

[0071] The 95th percentile (983.3 seconds, approximately 16.4 minutes) is well above average, indicating that about 5% of vehicles experienced significant delays, which could be related to sudden congestion, accidents, construction, or bottlenecks.

[0072] 3. Instability: High standard deviation and long tail distribution indicate significant instability in the traffic system, requiring further investigation into the root causes (e.g., traffic light timing, lane design, or network capacity).

[0073] Recommendation: Adjust traffic light timings or lane designs by combining traffic flow and waiting time data to prioritize traffic flow and improve overall traffic efficiency.

[0074] The following are the output results of the large model for emissions and fuel analysis: Total CO2 emissions: 4986.30 tons; Total fuel consumption: 1616.47 liters; Total CO emissions: 54.81 tons; Total electricity consumption: 0.00 kWh; Total particulate matter emissions: 0.42 tons.

[0075] Emissions data characteristics and environmental assessment: 1. CO2 emissions (4986.30 tons): If the data represents total emissions for a specific region or period (e.g., monthly), its applicability needs to be determined based on traffic volume (e.g., number of vehicles and mileage). For example, if the region has a high average annual traffic volume, it may be within the normal range; if it is a small region, it may exceed environmental expectations.

[0076] Problem: CO2 is a major greenhouse gas, and optimization is needed if it does not meet national or international emission reduction targets (such as the Paris Agreement).

[0077] 2. CO emissions (54.81 tons): CO is a toxic gas that is harmful to health. The current value needs to be compared with local emission standards. If it exceeds the standard, it means that there may be a defect in the exhaust purification system (such as the three-way catalytic converter) or that the vehicle is aging.

[0078] 3. PMx emissions (0.42 tons): Low PMx (particulate matter) emissions indicate the potential for cleaner fuels (such as low-sulfur diesel) or exhaust treatment technologies (such as diesel particulate filters). However, it should be noted that if the vehicle is primarily diesel, PM emissions may still be high and require further verification.

[0079] 4. Fuel consumption (1616.47 liters): Fuel consumption is closely related to CO2 emissions. If vehicles are primarily gasoline-powered and have low fuel efficiency (e.g., due to frequent start-stop cycles or traffic congestion), then it is necessary to improve fuel economy to reduce emissions.

[0080] 5. Electricity consumption (0 kWh): Zero electricity consumption means that there are no electric vehicles in the current transportation system. If the goal is a low-carbon transition, it is necessary to accelerate the promotion of new energy vehicles (such as electric buses and shared electric vehicles).

[0081] Environmental Expectations and Issues 1. Compliance: If the area is industrial or a high-density city, emissions may be at a moderate level; however, if it is an ecological protection zone or a low-carbon demonstration zone, emissions may exceed environmental protection expectations.

[0082] Key issues: CO emissions did not meet the standards (for example, the CO limit in China's "Integrated Emission Standard for Air Pollutants" is 200 mg / m³). 3 ).

[0083] It consumes zero electricity and lacks the impetus for a transition to new energy sources.

[0084] 2. Potential risks: High CO2 and CO emissions could exacerbate air pollution and climate change, and should be prioritized for control.

[0085] PMx emissions were low, but further verification is needed to determine whether this was due to the testing method or vehicle type (such as a high proportion of light vehicles).

[0086] Suggestions for improvement 1. Promote new energy vehicles: Promote alternative fuel vehicles, such as electric vehicles and hydrogen-powered vehicles, to reduce CO2 and CO emissions.

[0087] Provide subsidies or policy incentives (such as charging pile construction and vehicle purchase discounts).

[0088] 2. Optimize traffic management: By reducing idling and frequent start-stop cycles through intelligent traffic lights and congestion pricing, CO and fuel consumption can be reduced.

[0089] Encourage public transportation and shared mobility to reduce the use of private cars.

[0090] 3. Strengthen emissions monitoring: Regularly test vehicle emissions and phase out high-polluting vehicles.

[0091] Promote clean fuels (such as low-sulfur diesel and biofuels) and exhaust purification technologies (such as particulate filters).

[0092] 4. Data Supplementation and Analysis: Define the time range of the data (e.g., year / month) and analyze it based on parameters such as traffic flow and vehicle type.

[0093] Compare regional / national emission standards and formulate targeted emission reduction targets.

[0094] Summarize Current data indicates that the transportation system still relies heavily on gasoline-powered vehicles, resulting in high CO2 and CO emissions and significant environmental impact. Environmental impact should be reduced through new energy transition, traffic optimization, and emissions monitoring. If the goal is to achieve air quality standards, these measures should be prioritized, and their effectiveness should be monitored regularly.

[0095] Experimental results show that the present invention can efficiently generate multi-dimensional traffic simulation scenarios. The scenarios are reasonable and conform to actual traffic dynamics, providing a reliable foundation for large-scale automated simulation and optimization.

[0096] To verify the contribution of the RAG-MCP module to scene generation, ablation experiments were conducted. The RAG-MCP module was removed, while 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; the success rate further decreased with the increase of the number of candidate tools, indicating that this module is crucial for handling complex tasks and maintaining consistency in generated scenes. The complete model outperformed the model without RAG-MCP in all configurations, for example, with 50 tools, the success rate was 0.92 compared to 0.72, and with 100 tools, the success rate was 0.87 compared to 0.53.

[0097] Table 2. Ablation study results on tool selection success rate with different numbers of tools. In summary, this invention relates to a semantically driven traffic simulation scenario generation method based on a large language model. By combining a large language model with a traffic knowledge base, it can automatically generate simulation scenarios that conform to actual travel patterns, significantly improving the automation, accuracy, and efficiency of the simulation process, reducing human intervention, and effectively enhancing the operability and application value of traffic simulation results.

[0098] The preferred embodiments of the present invention have been described in detail above. It should be understood that those skilled in the art can make numerous modifications and variations based on the concept of the present invention without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of the present invention through logical analysis, reasoning, or limited experimentation on the basis of existing technology should be within the scope of protection defined by 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.

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. This indicates 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, 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 collection 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. .

8. The semantic-driven traffic simulation scene generation method based on a large language model according to claim 1, characterized in that, 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. .

9. 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.

10. 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 different methods in generating simulation scenarios, 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

  • Urban traffic automatic simulation plug-in based on large language model and implementation method

    CN120671497A

  • 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

Cited By

  • Traffic signal collaborative optimization control method and device based on large language model

    CN122223985A