G-Sim: Generative Simulations with Large Language Models and Gradient-Free Calibration

Samuel Holt, Max Ruiz Luyten, Antonin Berthon, Mihaela van der Schaar

Introduction

Simulations are indispensable tools for decision-making in high-stakes domains such as healthcare and logistics. They enable "what-if" analysis without the risks associated with real-world experimentation. However, current approaches face a significant "catch-22": manual construction is labor-intensive and requires deep domain expertise, while purely data-driven models (e.g., Transformers) often act as "black boxes" that fail to generalize to out-of-distribution (OOD) scenarios.

G-Sim addresses this gap by introducing a hybrid framework that automates the creation of robust, interpretable, and "intervenable" simulators. By combining the structural reasoning of Large Language Models (LLMs) with rigorous, gradient-free empirical calibration, G-Sim produces code that accurately reflects real-world dynamics even under novel policy changes or structural stress tests.

The G-Sim Framework

G-Sim operates through an iterative refinement loop designed to satisfy four key properties: System-wide Experimentation (P0), Plausible Generalization (P1), Empirical Alignment (P2), and Data Form Consistency (P3).

The G-Sim iterative refinement loop combines LLM-driven structural design with gradient-free calibration techniques like SBI and Evolutionary Strategies.

The process consists of three primary phases:

  1. Propose (LLM-Driven Structural Design): An LLM is prompted with domain knowledge to draft the simulator's core logic in Python. This step defines the causal relationships and submodules (e.g., viral transmission mechanics or inventory flow).
  2. Calibrate (Gradient-Free Parameter Optimization): Since these simulators are often stochastic or non-differentiable, G-Sim employs likelihood-free techniques. It uses Evolutionary Strategies (GFO) for point estimates and Simulation-Based Inference (SBI) to derive full posterior distributions, capturing parameter uncertainty.
  3. Refine (Diagnostics-Driven Feedback): The calibrated model is evaluated against real-world data using metrics like Wasserstein distance. If discrepancies are found, G-Sim generates a natural language feedback summary, which the LLM uses to refine the code in the subsequent iteration.

Benchmarks and Evaluation

The framework was evaluated on three complex environments:

  • COVID-19 SIR: A stochastic epidemiological model tracking population transitions.
  • Supply Chain: A multi-echelon inventory management task with partial observability.
  • Hospital Bed Scheduling: A discrete-event simulation involving patient arrivals for multiple diseases and resource allocation across ICU and standard beds.

Key Results

G-Sim demonstrates superior performance in both predictive accuracy and generalization. In the Hospital Bed task, G-Sim achieved a Wasserstein distance of 5.24, significantly outperforming the best black-box baseline (Transformer), which scored 199.

OOD Generalization and Policy Optimization

A core strength of G-Sim is its ability to handle interventions not present in the training data. In the COVID-19 scenario, the model accurately predicted the effects of various lockdown strategies by scaling internal infection parameters, a feat impossible for standard data-driven models.

G-Sim accurately predicts COVID-19 population dynamics under various lockdown scenarios (shaded regions), matching ground truth (GT) even in OOD settings.

Furthermore, policies optimized using G-Sim simulators were found to be nearly identical to those derived from ground-truth environments, validating the framework's utility for strategic planning.

Discussion and Limitations

While G-Sim offers a powerful bridge between reasoning and data, several challenges remain. Gradient-free optimization can become computationally expensive as the number of parameters increases. Additionally, the framework's success depends on the LLM's ability to propose a fundamentally sound structure; if the initial causal prior is flawed, calibration may not suffice. Future work will explore multi-scale time steps and active learning to further refine structural proposals.

Summary updated

BibTeX
@inproceedings{holt2025g,
  author = {Samuel Holt and Max Ruiz Luyten and Antonin Berthon and Mihaela van der Schaar},
  title = {{G-Sim: Generative Simulations with Large Language Models and Gradient-Free Calibration}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=PvkO6rIixC},
}
Figure