Automatic driving test scene generation method and system based on accident text data driving
By using a method driven by accident text data, autonomous driving test scenario code is generated in modules, which solves the problems of low efficiency and poor realism in the construction of test scenarios in existing technologies. It realizes efficient and executable simulation test scenario generation, supporting rapid iteration and high-fidelity verification of autonomous driving systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2026-04-02
- Publication Date
- 2026-07-03
AI Technical Summary
Existing autonomous driving simulation tests suffer from low efficiency in building high-quality test scenarios, poor realism, difficulty in reproducing real accidents, and high rates of code inconsistency and syntax errors, failing to meet the requirements of high-fidelity simulation testing.
By using a method driven by accident text data, core scene elements are extracted, simulation scene code is generated in modules, and a large language model combining retrieval enhancement generation mechanism and rule mapping is used to perform grammatical validity verification and correction, thus constructing a dynamic scene code library.
It significantly improves the efficiency and realism of test scenario construction, reduces syntax error rate, ensures simulation executability and the dynamic evolution capability of the scenario library, and meets the testing needs of rapid iteration of autonomous driving systems.
Smart Images

Figure CN122332276A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of autonomous driving simulation testing technology, and relates to an autonomous driving test scenario generation method and system, particularly an autonomous driving test scenario generation method and system based on accident text data. Background Technology
[0002] With the rapid development of autonomous driving technology, safety verification has become a core aspect of system research and development and deployment. The perception, decision-making, and control of autonomous driving systems rely entirely on the collaborative work of software algorithms and sensors, significantly increasing system complexity. Faced with the uncertainties and dangers of open road environments, systematic verification must be conducted in diverse and high-intensity testing environments.
[0003] Currently, the main testing methods for autonomous driving systems include closed-course testing, on-road testing, and simulation testing. Among these, simulation testing, due to its high efficiency, low cost, and lack of physical risk, has gradually become the mainstream method for autonomous driving safety assessment. Existing simulation platforms such as CARLA, LGSVL, and Apollo Simulator support closed-loop simulation of the entire chain from sensors to control systems, enabling high-frequency and wide-coverage safety testing without relying on physical vehicles.
[0004] However, one of the main challenges in current simulation testing is that the construction of high-quality test scenarios still heavily relies on manual design or limited sensor data acquisition. These methods have three significant limitations in practical use: First, modeling efficiency is low. Manually building scenarios requires setting the attributes and positions of each traffic element (such as roads, traffic participants, obstacles, etc.), which is time-consuming and labor-intensive, making it difficult to generate diverse test environments on a large scale. Test engineers need to write scenario description code line by line, and the construction cycle of a single complex scenario can take several days or even weeks, which cannot meet the needs of the rapid iteration of autonomous driving systems for the number of test scenarios.
[0005] Second, there is a lack of real-world relevance. Manually designed scenarios are often based on assumed rules and are difficult to cover high-risk, easily overlooked, or extreme accident situations in actual roads. The subjective experience of the designers determines the distribution of the hazard characteristics of the scenario, resulting in a large deviation between simulation verification results and reality, and making it impossible to effectively identify the failure modes of autonomous driving systems in real accidents.
[0006] Third, it is difficult to reproduce real-world accidents. Existing autonomous driving accidents often exist in the form of text reports or news articles, and traditional modeling methods struggle to convert these unstructured texts into executable scenario scripts. The natural language information in accident descriptions lacks precise spatiotemporal coordinates, making it impossible to directly map to the parameter configuration of the simulation platform, thus hindering in-depth analysis of high-risk events and testing of response mechanisms.
[0007] To address these issues, a new class of "data-driven" simulation scene generation methods has emerged in recent years, attempting to learn scene patterns from historical traffic data. However, these methods are mostly based on structured trajectory data collected by sensors (such as lane lines, GPS coordinates, and speed time series), making it difficult to cover the semantics of accidents at the textual level. Furthermore, these methods often lack interpretability, and the generated results lack semantically clear scene labels, limiting their direct application in high-fidelity simulation systems.
[0008] Meanwhile, breakthroughs in natural language processing and large language modeling technologies have provided a technological foundation for extracting structured, reasonable, and generative traffic information from massive amounts of unstructured text. However, when general-purpose large language models are directly applied to code generation for autonomous driving simulation scenarios, the lack of multi-type constraint coordination mechanisms, insufficient adaptation to domain-specific languages, and a lack of dynamic evolution capabilities result in poor consistency among elements, high grammatical error rates, and difficulty in self-optimization of the generated code, failing to meet the engineering requirements of high-fidelity simulation testing.
[0009] Furthermore, retrieval-enhanced generation (RAG) technology can effectively integrate historical scene fragments with real-time text semantic information, improving the accuracy and diversity of generated code. However, existing RAG technologies are mainly applied to natural language generation tasks, where the retrieval object is text fragments and the enhancement target is semantic relevance. Autonomous driving simulation scenario code generation faces unique technical challenges: the generated results must conform to the strict grammatical specifications of the domain-specific language, maintain consistency in variable naming and spatial logical correctness among elements, and possess physical executability. Existing RAG technologies are not adapted to these constraints; direct application will lead to problems such as variable conflicts between elements, high syntax error rates, and simulation execution failures.
[0010] In summary, how to efficiently and accurately generate test scenario scripts for simulation platforms from real traffic accident texts has become a key issue in the field of intelligent driving testing. Constructing an automatic scenario generation method from text to simulation, realizing a complete technical chain of accident semantic understanding, structured scenario mapping, constrained code generation, and simulation execution verification, has significant research and engineering application value. Summary of the Invention
[0011] To address the aforementioned issues, this invention provides a method and system for generating autonomous driving test scenarios based on accident text data.
[0012] The technical solution adopted in this invention is as follows: A method for generating autonomous driving test scenarios based on accident text data includes the following steps: Obtain accident text data and extract core scene elements from the accident text data; The core scene elements are reorganized and transformed into modular scene content descriptions, including weather and lighting modules, conflict behavior modules, road conditions modules, and vehicle location modules. Based on the scene content description, and following preset generation constraint rules, simulation scene code is generated in modules. The simulation scene code for the weather and lighting module is generated based on rule mapping or knowledge embedded in a large language model. The simulation scene codes for the conflict behavior module, road condition module, and vehicle position module are all generated using a retrieval-enhanced generation mechanism (RAG). The generation of the simulation scene code for the vehicle position module also incorporates the already generated simulation scene codes for the conflict behavior module and road condition module as contextual information. Combine the simulation scenario code of each module, generate the test scenario script, and execute the simulation test; If the simulation test fails, the code for the simulation scenario will be syntactically validated and corrected, and the simulation test will be re-executed until it passes.
[0013] Furthermore, the core scenario elements include traffic participant attributes, road structure characteristics, environmental and meteorological conditions, conflict type, and pre-collision behavior sequence.
[0014] Furthermore, the conflict behavior module, road condition module, and vehicle location module are generated using a retrieval-enhanced generation mechanism, specifically including: Construct a scene code vector library, which includes historical scene code fragments and their vectorized representations in natural language; The scene content description of the target module is encoded into a query vector, and relevant historical scene code fragments are retrieved from the scene code vector library based on semantic similarity. By combining the relevant historical scene code snippets with the scene content description of the target module, prompt words are constructed to guide the large language model to generate simulation scene code.
[0015] Furthermore, for the vehicle location module, the constructed prompt word also includes: The simulation scenario codes of the generated conflict behavior module and road condition module are used as context information, and together with the relevant historical scenario code fragments and scenario content descriptions, prompt words are constructed. When generating code based on the prompt words, the naming of constraint variables is consistent with the context information, and the correctness of spatial logic is verified.
[0016] Furthermore, the weather and illumination module is generated based on rule mapping or knowledge embedded in a large language model, including: The qualitative weather description is transformed into quantitative environmental parameters, which include at least one of cloud cover, precipitation intensity, surface water volume, wind intensity, solar altitude angle, and fog density.
[0017] Furthermore, the simulation scenario code undergoes syntax validity verification and correction, specifically including: A syntax knowledge vector library was built based on the official documentation of the simulation scenario code language. Identify high-error-rate syntax keywords in the simulation scenario code and retrieve the corresponding standard syntax descriptions from the syntax knowledge vector library; The standard syntax description and the simulation scenario code to be corrected are input into the large language model, and the syntax is corrected while maintaining semantic consistency.
[0018] Furthermore, the generation constraint rules include: The names of behavioral functions are standardized to preset identifiers; hyperparameters are defined in a unified format and called via global parameters; code is generated based on the syntax structure of historical scene code snippets obtained from retrieval, and the range of parameter values is adjusted to enhance the danger of the scene; For the vehicle location module, when obstacles are involved, the obstacle type is selected from a predefined set.
[0019] Furthermore, it also includes adding simulation scenario code that has passed simulation execution and whose safety assessment indicators meet the criteria for dangerous scenario determination as new historical scenario code fragments to the scenario code vector library.
[0020] An autonomous driving test scenario generation system based on accident text data, used to implement the above method, includes: The text understanding module is used to acquire accident text data and extract core scene elements; The feature reconstruction module is used to reorganize the core scene elements into scene content descriptions in sub-modules; The code generation module is used to generate simulation scene code in modules based on the scene content description and following preset generation constraint rules. The modular code generation module includes a weather and lighting code generation unit, a conflict behavior code generation unit, a road condition code generation unit, and a vehicle position code generation unit. The weather and lighting code generation unit is configured to generate code based on rule mapping or knowledge embedded in a large language model. The conflict behavior code generation unit, road condition code generation unit, and vehicle position code generation unit are configured to generate code using a retrieval-enhanced generation mechanism. The vehicle position code generation unit is also configured to introduce the simulation scene code of the already generated conflict behavior module and road condition module as context information. The code correction module is used to perform syntax and legality verification and correction on the simulation scenario code; The simulation execution module is used to combine the modified simulation scenario code of each module, generate test scenario scripts, and execute simulation tests.
[0021] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described method.
[0022] Compared with the prior art, the beneficial effects of the present invention are as follows: First, it significantly improves the efficiency of test scenario construction, enabling automated reproduction of accident texts. This invention overcomes the bottleneck of manual design, which relies on expert experience and is time-consuming, by constructing an end-to-end mapping link of "accident text, core scenario elements, structured description, and simulation scenario code." Compared to the construction cycle of manually writing scenario code, which takes several days to weeks, this invention can complete the transformation from unstructured accident descriptions to executable scenario scripts in a very short time. This significantly improves scenario construction efficiency and meets the needs of rapid iteration in autonomous driving systems for a massive number of test scenarios.
[0023] Second, it enhances the realism of the test scenarios, covering high-risk situations where sensor data is difficult to collect. This invention directly parses qualitative semantic information (such as weather conditions, conflict types, and pre-collision behavior sequences) from accident texts, transforming it into quantitative simulation parameter configurations. This overcomes the limitation of sensor data-driven methods, which can only learn from structured trajectory data. Compared to long-tail scenarios such as extreme weather, complex interactions, and rare accident types that are difficult to cover by existing methods, this invention can systematically reproduce historical real accidents, significantly improving the hazard representativeness and coverage of the test scenarios.
[0024] Third, this invention improves the consistency and syntactic validity of the generated code across modules, ensuring simulation executability. Through a differentiated generation mechanism design, this invention employs adapted generation strategies for different element types such as weather conditions, traffic behavior, road structure, and entity location, and establishes a context constraint mechanism between elements, resolving variable naming conflicts and spatial logic errors caused by general end-to-end generation. Simultaneously, by constructing a domain-specific language syntactic knowledge vector library, combined with semantic retrieval and model error correction, the legality verification and correction of the generated code are achieved, significantly reducing the syntax error rate and significantly improving simulation executability.
[0025] Fourth, the invention enables dynamic evolution and self-optimization of the scenario library, continuously improving the quality of generated scenarios. It also establishes a closed-loop feedback mechanism of "generation, execution, evaluation, screening, storage, and re-retrieval," continuously adding verified high-risk scenario code to the scenario code vector library in real time, overcoming the limitation of static knowledge bases that cannot evolve with testing needs. As the system's runtime increases, the risk distribution of the scenario library gradually aligns with the actual accident distribution, continuously improving the testing effectiveness and risk targeting of generated scenarios.
[0026] In summary, this invention, through the systematic integration of accident semantic understanding, differentiated generation mechanism, contextual constraint collaboration, grammatical validity guarantee, and dynamic evolution capability, constructs a complete technical chain from unstructured accident text to highly executable simulation scenario code, providing an efficient, high-coverage, and high-fidelity test scenario generation solution for autonomous driving safety verification. Attached Figure Description
[0027] Figure 1 This is an overall flowchart of the method in an embodiment of the present invention. Detailed Implementation
[0028] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.
[0029] Example 1 This embodiment uses a case from April 15, 2024, in which a vehicle in autonomous driving mode failed to recognize a large vehicle parked ahead and caused a rear-end collision, to demonstrate the complete process of the autonomous driving hazardous scene generation method based on accident text data described in this invention. The generated code uses the Scenic scene description language and can be directly executed on autonomous driving simulation platforms (such as CARLA, LGSVL, or other high-fidelity environments that support Scenic scripts).
[0030] S1: Text Data Collection and Feature Extraction The following accident description text was received: "On April 15, 2024, a certain brand of vehicle received a complaint from its owner related to this car accident. The owner claims that she 'put her car in autopilot mode while it was raining, the vehicle did not detect the large truck, and when she braked, the vehicle collided with the truck.'" Supplement information using structured fields: Accident time Road type Road surface condition Light conditions Weather conditions Accident subject Behavior of the other vehicle before the collision Vehicle behavior before collision 15:09 Streets and roads Slippery roads sunlight Cloudy, rainy truck parking go ahead
[0031] Core scene elements were extracted from the above text using a large language model, including: Traffic participant attributes: private vehicle (car), conflict object (truck) Road structural features: Two-lane urban street, straight road Environmental and meteorological conditions: Cloudy, rainy, slippery roads, sunshine Type of conflict: Rear-end collision Pre-collision behavior sequence: Truck stops, vehicle moves forward S2: Feature Reconstruction and Modular Description The extracted core scene elements undergo information extraction and semantic reconstruction, transforming them into modular scene content descriptions:
[0032] S3: Generating simulation scene code in modules Based on the above scenario description, and following the preset generation constraint rules, simulation scenario code is generated in modules.
[0033] S3.1: Weather module generation By directly utilizing the embedded knowledge of the large language model, qualitative weather descriptions are transformed into quantitative environmental parameters. The following prompt words are constructed: You are a professional weather parameter conversion expert. Generate suitable weather parameters for the CARLA simulator based on the following weather description: '3:09 PM, Cloudy, Moderate Rainfall, Wet Asphalt Surfaces, Sunny Conditions'. Please strictly adhere to the following parameter definitions to return results in JSON format: 'cloudiness': Integer from 0-100, representing cloud cover; 'precipitation': Integer from 0-100, representing precipitation intensity; 'precip_deposits': Integer from 0-100, representing the amount of water on the ground; 'wind_intensity': Integer from 0-100, representing wind intensity; 'sun_altitude_angle': Integer from -90 to 90, representing the solar altitude angle (negative values indicate nighttime); 'fog_density': Integer from 0-100, representing fog density.
[0034] Generate code example:
[0035]
[0036] S3.2: Generation of Conflict Behavior and Road Condition Modules (Geometry) A retrieval-enhanced generation mechanism is employed. First, a scene code vector library is constructed. In this embodiment, the HuggingFace open-source model 'sentence-transformers / sentence-t5-large' is used to vectorize historical scene code fragments and their natural language descriptions for semantic similarity retrieval.
[0037] In this embodiment, the conflict behavior module and the road condition module use the same retrieval enhancement generation mechanism, generating corresponding codes for the behavior description and road description, respectively. Taking the conflict behavior module as an example, a prompt word combining semantic enhancement, grammatical constraints, and format control is constructed, including two parts: system prompt words and user prompt words. The API temperature parameter is set to 0.3.
[0038] For the conflict behavior module, the scenario description "a conflicting truck suddenly brakes in front of the vehicle, creating a critical situation" is encoded into a query vector. Based on semantic similarity, the top K most similar related historical scenario code snippets are retrieved and used to construct prompt words.
[0039] Constructing prompt words to guide the large language model in generating simulation scene code: System prompt: Your goal is to help me write a snippet for CARLA simulations using Scenic 2.1. Scenic is a domain-specific probabilistic programming language designed for modeling environments in cyber-physical systems. Always wrap your code in 'scenic code' format.
[0040] User prompt: Your task is now to help write part of the Scenic code to define the adversarial behavior of an agent given a corresponding description. Here are some relevant description-code snippet pairs: [Retrieved historical scene code snippet]. Now, provide a code snippet for the following description. Note that if there is already a code snippet in the example that matches the description, return that snippet directly. Otherwise, construct the code snippet using the same format as above. Note that the behavior function name should always be AdvBehavior, and any hyperparameters should be defined as param OPT_xxx and used with globalParameters.OPT_xxx in the behavior function. Please strictly follow the syntax used in the example; you can change the range values to make the scene as dangerous as possible. Description: [A conflict truck suddenly brakes in front of the vehicle, creating a critical situation].
[0041] Based on the aforementioned prompts, the large language model generates simulation scene code. This mechanism significantly improves the accuracy, consistency, and semantic fit of the Scenic code output by the LLM, and ensures that the generated results can be directly concatenated and conform to grammatical specifications by adding format constraints (such as unifying function names to AdvBehavior, unifying parameter names to param OPT_xxx, and unifying the use of globalParameters for calls).
[0042] The road condition module is generated using the same mechanism.
[0043] The generated code example is as follows:
[0044]
[0045] S3.3: Vehicle Location Module Generation The generation mechanism is enhanced by retrieval, and the simulation scenario code of the already generated conflict behavior module and road condition module is introduced as context information.
[0046] The generated simulation scenario code of the conflict behavior module and road condition module is combined with the retrieved relevant historical scenario code fragments and scenario content descriptions to construct prompt words. This context fusion mechanism constrains the generated code to maintain consistency in variable naming and spatial logic with the generated modules, improving the accuracy in terms of positional logic, syntax consistency and structural alignment.
[0047] The prompt consists of two parts: a system prompt and a user prompt. The system prompt is the same as in step S3.2, and the user prompt is as follows: Your task is to help write part of the Scenic code to define the spawn points for the adversarial agent, given the corresponding descriptions. Here are some relevant description-code snippet pairs: [Retrieved historical scene code snippets]. Now, provide code snippets for the following descriptions. Note that if a code snippet already exists in the examples that matches the description, return that snippet directly. Otherwise, construct a new code snippet following the format provided above. Note that any hyperparameters should be defined as param OPT_xxx and used as globalParameters.OPT_xxx. If obstacles are involved, they must also be defined. Obstacles can only be selected from the following options: "Car", "ATM", "Barrel", "Obstacle", "Bench", "Bus Stop", "Chair", "Debris", "Trash", "Mailbox". Furthermore, you must ensure that variable names are consistent with those defined in the generated geometry and behavior snippets, and that the spatial location and orientation angle of the spawn points match the road structure and behavior logic. Do not use syntax other than that used in the examples; you can change random values to make the scene as dangerous as possible. In addition, there are already generated geometry and behavior fragments: [Generated conflict behavior module code and road condition module code]. Description: [A conflicting truck is directly in front of the ego vehicle in the same lane, partially obstructing the ego vehicle's forward visibility].
[0048] The generated code example is as follows:
[0049] S4: Syntax Validation and Correction Combine the simulation scenario code of each module to generate a test scenario script, and load it into the CARLA simulation platform to perform simulation tests.
[0050] If the scene loads normally and the vehicle's position, direction, and behavior are all logical, then proceed to step S5 to perform simulation evaluation and feedback extension.
[0051] If the simulation scenario code cannot run normally in the CARLA simulation platform, then perform syntax validity verification and correction: First, a grammar knowledge vector library is built based on the official documentation of the Scenic language (including papers, developer manuals, and online documentation), and an embedding model is used to vectorize the grammar description text.
[0052] Identify high-error-rate syntax keywords in simulation scene code, including lane definition keywords (lane), offset keywords (offset), heading keywords (heading), and direction keywords (direction).
[0053] For example, in one embodiment of the present invention, the matched keywords include "offset" and "heading".
[0054]
[0055] The corresponding standard syntax description is retrieved from the syntax knowledge vector library. The standard syntax description and the simulation scenario code to be corrected are input into the large language model, and the syntax is corrected while maintaining semantic consistency.
[0056] The following are the constructed prompt words: You are a Scenic language expert. Please modify the given code according to the provided documentation, paying particular attention to syntax errors and undefined variables. Do not modify the code structure or logic. Output only the corrected Scenic code (code content only, no explanation). Important: Only return the code content, not any formatting tags (e.g., orscenic), and do not remove any globalParams. The Scenic code to be modified: [code_draft]. The documentation from the Scenic paper: [doc_text]. Where: {code_draft} is the code snippet to be modified; {doc_text} is the syntax description for this keyword.
[0057] The corrected code section is as follows:
[0058] The revised simulation scenario code was reloaded into the CARLA simulation platform to perform simulation tests until the verification was successful.
[0059] S5: Simulation Execution and Evaluation Load the scenario into the CARLA simulation platform, start the autonomous driving system, and execute the complete test process. The simulation results are as follows:
[0060] S6. Scene Code Vector Library Extension In this embodiment, since the generated Scenic code can run smoothly and all indicators in the simulation results show that the accident case is a representative dangerous scenario for autonomous driving, the simulation scenario code is added to the scenario code vector library as a new historical scenario code fragment to realize the dynamic expansion of the vector library.
[0061] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0062] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0063] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0064] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0065] The above specific embodiments are used to explain and illustrate the present invention, but not to limit the present invention. Any modifications and changes made to the present invention within the spirit and scope of the claims shall fall within the protection scope of the present invention.
Claims
1. A method for generating autonomous driving test scenarios based on accident text data, characterized in that, Includes the following steps: Obtain accident text data and extract core scene elements from the accident text data; The core scene elements are reorganized and transformed into modular scene content descriptions, including weather and lighting modules, conflict behavior modules, road conditions modules, and vehicle location modules. Based on the scene content description, and following preset generation constraint rules, simulation scene code is generated in modules; The simulation scene code for the weather and lighting module is generated based on rule mapping or knowledge embedded in a large language model. The simulation scene codes for the conflict behavior module, road condition module, and vehicle position module are all generated using a retrieval-enhanced generation mechanism. The generation of the simulation scene code for the vehicle position module also incorporates the already generated simulation scene codes for the conflict behavior module and road condition module as contextual information. Combine the simulation scenario code of each module, generate the test scenario script, and execute the simulation test; If the simulation test fails, the code for the simulation scenario will be syntactically validated and corrected, and the simulation test will be re-executed until it passes.
2. The method for generating autonomous driving test scenarios based on accident text data according to claim 1, characterized in that, The core scenario elements include traffic participant attributes, road structure characteristics, environmental and meteorological conditions, conflict types, and pre-collision behavior sequences.
3. The method for generating autonomous driving test scenarios based on accident text data according to claim 1, characterized in that, The conflict behavior module, road condition module, and vehicle location module are generated using a retrieval-enhanced generation mechanism, specifically including: Construct a scene code vector library, which includes historical scene code fragments and their vectorized representations in natural language; The scene content description of the target module is encoded into a query vector, and relevant historical scene code fragments are retrieved from the scene code vector library based on semantic similarity. By combining the relevant historical scene code snippets with the scene content description of the target module, prompt words are constructed to guide the large language model to generate simulation scene code.
4. The method for generating autonomous driving test scenarios based on accident text data according to claim 3, characterized in that, For the vehicle location module, the constructed prompt word further includes: The simulation scenario codes of the generated conflict behavior module and road condition module are used as context information, and together with the relevant historical scenario code fragments and scenario content descriptions, prompt words are constructed. When generating code based on the prompt words, the naming of constraint variables is consistent with the context information, and the correctness of spatial logic is verified.
5. The method for generating autonomous driving test scenarios based on accident text data according to claim 1, characterized in that, The weather and illumination module is generated based on rule mapping or knowledge embedded in a large language model, including: The qualitative weather description is transformed into quantitative environmental parameters, which include at least one of cloud cover, precipitation intensity, surface water volume, wind intensity, solar altitude angle, and fog density.
6. The method for generating autonomous driving test scenarios based on accident text data according to claim 1, characterized in that, The simulation scenario code undergoes syntax validity verification and correction, specifically including: A syntax knowledge vector library was built based on the official documentation of the simulation scenario code language. Identify high-error-rate syntax keywords in the simulation scenario code and retrieve the corresponding standard syntax descriptions from the syntax knowledge vector library; The standard syntax description and the simulation scenario code to be corrected are input into the large language model, and the syntax is corrected while maintaining semantic consistency.
7. The method for generating autonomous driving test scenarios based on accident text data according to claim 1, characterized in that, The generation constraint rules include: The names of behavioral functions are standardized to preset identifiers; hyperparameters are defined in a unified format and called via global parameters; code is generated based on the syntax structure of historical scene code snippets obtained from retrieval, and the range of parameter values is adjusted to enhance the danger of the scene; For the vehicle location module, when obstacles are involved, the obstacle type is selected from a predefined set.
8. The method for generating autonomous driving test scenarios based on accident text data according to claim 1, characterized in that, Also includes: Simulation scenario code that passes simulation execution and whose safety assessment indicators meet the criteria for dangerous scenario determination will be added to the scenario code vector library as new historical scenario code fragments.
9. A system for generating autonomous driving test scenarios based on accident text data, characterized in that, To implement the method of any one of claims 1-8, comprising: The text understanding module is used to acquire accident text data and extract core scene elements; The feature reconstruction module is used to reorganize the core scene elements into scene content descriptions in sub-modules; The code generation module is used to generate simulation scene code in modules based on the scene content description and following preset generation constraint rules. The modular code generation module includes a weather and lighting code generation unit, a conflict behavior code generation unit, a road condition code generation unit, and a vehicle position code generation unit. The weather and lighting code generation unit is configured to generate code based on rule mapping or knowledge embedded in a large language model. The conflict behavior code generation unit, road condition code generation unit, and vehicle position code generation unit are configured to generate code using a retrieval-enhanced generation mechanism. The vehicle position code generation unit is also configured to introduce the simulation scene code of the already generated conflict behavior module and road condition module as context information. The simulation execution module is used to combine the simulation scenario code of each module, generate test scenario scripts, and execute simulation tests. The code correction module is used to perform syntax and legality verification and correction on simulation scenario code that fails the simulation test.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-8.