TL;DR
This paper introduces TARGET, an automated framework that generates realistic driving test scenarios for autonomous vehicles (AVs) directly from natural language traffic rules. By leveraging Large Language Models (LLMs) and a novel Domain-Specific Language (DSL), TARGET significantly reduces the manual effort in AV testing and has successfully uncovered hundreds of rule violations and critical issues in seven different AV systems.
What Problem Does This Paper Address?
Ensuring the safety and robustness of autonomous driving systems (ADSs) is paramount, especially given recent incidents. A critical part of this is rigorous testing using a wide variety of scenarios. However, manually creating these test scenarios is incredibly time-consuming and complex. Existing methods often rely on intricate, verbose, and map-dependent Domain-Specific Languages (DSLs) like OpenSCENARIO, making scenario generation a bottleneck. While LLMs show promise for understanding natural language rules, they struggle with the complexity of these DSLs and are prone to generating inaccurate or hallucinated scenarios. This paper tackles the challenge of efficiently and accurately generating diverse test scenarios from natural language traffic rules to improve AV safety.
Methods
TARGET employs a multi-stage, LLM-guided approach:
- LLM-based Traffic Rule Parsing: The core innovation is using an LLM (specifically GPT-4) to parse natural language traffic rules. To overcome LLM limitations like hallucination and context complexity, the authors introduce a novel, simple, compositional, and syntactically validated Domain-Specific Language (DSL). This DSL allows for modular scenario representation. The LLM is guided through a pipeline involving:
- Few-shot In-context Learning: Providing the LLM with examples to learn the DSL's structure and desired output format.
- Knowledge Validation: An LLM-driven step to ensure the extracted information aligns with the original traffic rule.
- Syntax Alignment: Ensuring the LLM's output conforms to the precise elements defined in the DSL.
- Template-based Test Script Generation: Once an abstract scenario representation is generated using the DSL, TARGET converts it into executable scripts for simulators. This involves:
- Dictionary Search: Mapping abstract environmental and oracle elements (e.g., "clear weather," "yield") to simulator-specific parameters.
- Hierarchical Map-based Route Search: A sophisticated algorithm to determine precise actor (ego vehicle and NPCs) initial and destination coordinates by analyzing simulator map data and identifying suitable routes that satisfy the scenario's constraints.
- Scenario Monitor: After execution in a simulator, a monitor records scenario data, including actor positions and speeds, to identify rule violations, collisions, and timeouts.
Datasets
- Texas Driver Handbook: A benchmark of 98 traffic rules was created from this handbook, focusing on rules with accompanying figures and excluding non-driving scenarios or non-vehicular behaviors. Ground truth scenario representations were independently created by the authors.
- Simulators: The framework was evaluated using CARLA, LGSVL, and MetaDrive simulators.
- Maps: Experiments utilized eight maps in CARLA (Town 1-7, Town 10) and four in LGSVL (San Francisco, Shalun, Gomentum, Cubetown). Some maps were augmented with additional assets (e.g., traffic signs) to increase compatibility.
- ADSs: Seven autonomous driving systems were tested: Auto, MMFN, LAV, Autoware, Apollo 7.0, IDM, and PPO.
Key Insights and Ideas
- LLMs + Simple DSL = Powerful Scenario Generation: The combination of LLMs for natural language understanding and a well-designed, simple DSL is key to overcoming the limitations of both traditional DSLs and direct LLM-based script generation. The DSL acts as a crucial intermediary, simplifying the LLM's task and mitigating hallucinations.
- Modular Validation is Crucial: The multi-step LLM pipeline (extraction, validation, alignment) is essential for ensuring the accuracy and consistency of the generated scenario representations.
- Abstract Scenarios for Generalizability: The DSL allows for abstract scenario definitions that can be instantiated across different simulation maps and potentially different simulators, reducing the need for manual adaptation.
- Real-World Rule Compliance: Generating scenarios directly from traffic rules ensures that the tests are grounded in real-world driving expectations, making the detected violations more relevant to actual safety concerns.
Key Results
- High Scenario Generation Success: TARGET successfully generated executable test scenarios for 90% of the rules, with only 7% encountering compile errors and 3% runtime errors (often attributed to simulator bugs).
- Effective Rule Violation Detection: Across seven ADSs and 284 generated scenarios, TARGET uncovered 610 rule violations, collisions, and other issues.
- High Accuracy in Scenario Matching: Human evaluations (by students and professional workers) indicated that the generated scenarios largely matched the intended traffic rules, with most votes falling into "Totally match" or "Mostly match" categories. Fleiss' Kappa scores indicated substantial agreement among raters.
- Confirmation of Issues: Two identified issues were confirmed by ADS developers, one linked to an existing bug report and another to limited ADS functionality.
- LLM Performance: GPT-4, especially with the full pipeline (KE, KV, SA), showed significantly higher accuracy in parsing traffic rules compared to GPT-3.5 and GPT-3. Open-source LLMs like Llama3.1-70b showed comparable performance to GPT-3.5.
Limitations and Future Work
- DSL Limitations: The current DSL might not support highly complex scenarios involving multiple consecutive driving behaviors, which can lead to parsing failures for certain rules.
- Simulator Bugs: Some generated scenarios failed due to inherent bugs or limitations in the CARLA simulator's API.
- LLM Hallucinations: While mitigated, LLMs can still sometimes be confused about actor behaviors or expected driving actions, especially when inferring implicit information.
- Future Work:
- Refining the DSL: Expanding the DSL to support more complex driving behaviors.
- Multi-modal LLMs: Integrating multi-modal LLMs to parse diverse sources like accident reports with text and sketches.
- Fuzzing and Search-Based Algorithms: Combining TARGET with fuzzing and search-based methods to mutate scenarios and generate more rule-violating test cases.
- Hybrid Approach: Developing a hybrid system that combines the efficiency of automation with the precision of manual control for scenario parameter definition.
- Expanding Rule Sources: Incorporating traffic rules from other regions and countries.
Summary updated