ML-SceGen: A Multi-level Scenario Generation Framework

Yicheng Xiao, Yangyang Sun, Yicheng LinarXiv 2025 · DOI

Testing autonomous vehicles (AVs) presents a significant "long-tail" challenge. While standard driving conditions are easily simulated, rare and dangerous "edge cases" are difficult to systematically discover or recreate. Existing methodologies often struggle with a trade-off between scalability, controllability, and logical validity. Manual modeling is slow; generative AI lacks precise control; and pure Large Language Model (LLM) approaches are prone to logical "hallucinations."

To address these gaps, we present ML-SceGen, a multi-level framework that bridges the gap between vague natural language descriptions and precise, safety-critical simulation scenarios. By combining the creative reasoning of LLMs with the rigorous formal logic of Answer Set Programming (ASP), ML-SceGen enables the generation of diverse, controllable, and physically valid "dangerous" testing environments.

The ML-SceGen Framework

ML-SceGen operates through a structured three-stage pipeline that transforms a simple text prompt into a complex, executable simulation.

Overview of the ML-SceGen three-stage generation process.

Stage 1: Multi-agent Parser (Functional Scenario)

The process begins with a natural language prompt. LLM agents, built using the LangChain framework, extract key components such as the number of vehicles, entry points, and road types. This stage defines the "Functional Scenario"—a high-level description of the intended traffic situation.

Stage 2: ASP Solver (Logical Scenario)

The core innovation of ML-SceGen lies in its use of Answer Set Programming (ASP) via the clingo solver. ASP formalizes intersection rules and constraints to identify every valid traffic flow configuration. To optimize efficiency, the framework employs mathematical symmetry (e.g., recognizing that a left turn from the North is logically equivalent to one from the East), significantly pruning the search space.

Stage 3: Parameter Update & Generation (Concrete Scenario)

In the final stage, LLM agents identify "danger factors" such as speeding, sudden braking, or aggressive lane changes. These factors are used to update scenario parameters. The framework then utilizes the scenariogeneration Python library to convert these parameters into industry-standard OpenScenario and OpenDrive XML files, ready for execution in simulators like CARLA or Esmini.

Multi-Agent Parsing and Danger Injection

The framework relies on specialized agents to handle the nuances of user intent and environmental complexity.

The multi-agent architecture for parsing user prompts and identifying danger factors.

Traffic Agents handle explicit and ambiguous scenarios by either direct parsing or reasoning through possible configurations. Concurrently, Danger Factor Agents—including Car Setup, Lane Change, and Weather Agents—refine the scenario by solving for car juxtaposition, encoding dangerous factors from vector stores, and predicting likely weather conditions for the given scenario.

Key Insights and Results

The integration of formal logic via ASP ensures that generated scenarios are physically possible and logically sound, avoiding the common pitfalls of pure LLM generation. By applying symmetry reduction, the authors reduced the search space for a 3-car intersection from 8 cases to 4, demonstrating significant computational gains.

Evaluation across 11 custom-defined test cases (including T-junctions, roundabouts, and Y-intersections) yielded the following results:

  • Parsing Accuracy: The LLM agents achieved 100% correctness in extracting road and vehicle information.
  • Reliability: The overall framework correctness was approximately 82% (9/11 cases).
  • Controllability: Users successfully modified parameters like road angles and speeds to increase scenario "criticality."

Conclusion and Future Work

ML-SceGen provides a transparent, multi-level abstraction for scenario design that mirrors human engineering processes. While currently focused on uncontrolled intersections and vehicle-only traffic, future iterations aim to include pedestrians, cyclists, and more complex road geometries. Addressing API compatibility issues with simulators like CARLA and developing more nuanced evaluation metrics remain key priorities for future development.

Summary updated

BibTeX
@misc{xiao2025ml,
  author = {Yicheng Xiao and Yangyang Sun and Yicheng Lin},
  title = {{ML-SceGen: A Multi-level Scenario Generation Framework}},
  year = {2025},
  eprint = {2501.10782},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.10782},
}
Figure