LLM and Simulation as Bilevel Optimizers: A New Paradigm to Advance Physical Scientific Discovery

Pingchuan Ma, Tsun-Hsuan Wang, Minghao Guo, Zhiqing Sun, Joshua B. Tenenbaum, Daniela Rus, Chuang Gan, Wojciech Matusik

Introduction

Automating scientific discovery has long been a primary goal for artificial intelligence. However, current approaches are often lopsided. Large Language Models (LLMs) possess extensive "book knowledge" and reasoning capabilities but struggle to ground their ideas in physical reality—they cannot inherently determine if a proposed physics equation is stable or if a molecular structure is physically viable. Conversely, traditional simulations provide precise physical feedback but lack the creative capacity to propose entirely new theories or structures.

To bridge this gap, researchers have introduced the Scientific Generative Agent (SGA), a framework that treats LLMs and physical simulations as a unified "bilevel" team. In this paradigm, the LLM acts as the theorist, proposing discrete structures, while a differentiable simulation acts as the laboratory, fine-tuning continuous parameters to match real-world data.

The SGA Framework: Bilevel Optimization

SGA operates through a structured feedback loop known as bilevel optimization. This process divides the discovery task into two distinct but interconnected levels:

  1. Outer-Level (LLM-Driven): The LLM (e.g., GPT-4) acts as the high-level "thinker." It proposes hypotheses in the form of executable Python code, such as a PyTorch module defining a material's stress-strain relationship. The agent employs an Exploit-and-Explore strategy, alternating between refining successful previous attempts and exploring radical new theoretical directions.
  2. Inner-Level (Simulation-Driven): The proposed code is passed to a differentiable simulator. Because the simulation is differentiable, it can utilize gradient descent to automatically optimize continuous parameters—such as material stiffness or atomic coordinates—to minimize error against ground-truth data.
The SGA framework architecture showing the bilevel optimization loop between the LLM and the differentiable simulation.

This loop is closed by feeding the simulation results (loss curves, trajectories, and optimized parameters) back to the LLM. The agent then analyzes why a previous attempt failed or succeeded, using this observational feedback to propose a superior hypothesis in the next iteration.

Experimental Domains

The framework was evaluated across several challenging scientific domains:

  • Constitutive Law Discovery: Identifying the underlying physics of materials, ranging from linear elastic solids to complex, weakly compressible fluids.
  • Molecular Design: Targeting specific quantum mechanical properties (such as HOMO/LUMO energy gaps) using the QM9 dataset.
  • Symbolic Regression: Testing against the SRBench benchmark to discover mathematical expressions directly from data.

The Synergy of Bilevel Optimization

A critical insight from this research is the "zigzag" synergy between the two levels of optimization. Ablation studies demonstrate that the LLM and simulation are mutually reinforcing: the LLM provides a sophisticated starting point for the simulation, while the simulation's optimization provides a clear signal for the LLM to reason about the underlying discrete structure.

Ablation study illustrating the 'zigzag' synergy where LLM-driven outer optimization and simulation-driven inner optimization work together to minimize loss.

By using code as a universal language, the framework remains domain-agnostic. The same system can transition from physics to chemistry with minimal prompting changes. Furthermore, to ensure the model wasn't simply "memorizing" known physics, the authors tasked it with discovering an "imaginary" constitutive law—a hybrid of plastic, granular, and fluid properties that does not exist in nature. SGA successfully discovered the law, proving its ability to reason through novel physical phenomena.

Key Results and Innovation

SGA demonstrates significant improvements over existing automated discovery methods:

  • Superior Accuracy: In constitutive law discovery, SGA achieved losses several orders of magnitude lower than baselines like FunSearch or Eureka. For instance, in certain tasks, SGA's loss was 5.2e-5 compared to the next best baseline's 90.2.
  • Molecular Innovation: In chemistry tasks, SGA discovered novel structures that met target quantum properties more accurately than traditional population-based methods.
  • Efficiency: While high-quality LLM inference is computationally intensive, SGA converges much faster and more reliably than methods lacking a bilevel structure.

Conclusion and Future Work

The SGA framework represents a significant step toward autonomous scientific discovery by combining the reasoning of LLMs with the empirical precision of simulations. Future work will focus on improving the interpretability of generated code, ensuring AI safety through sandboxed execution environments, and adapting the inner loop for non-differentiable simulators using zero-order optimizers. As LLM costs decrease and capabilities grow, this bilevel paradigm offers a scalable path toward uncovering the next generation of scientific laws.

Summary updated

BibTeX
@inproceedings{ma2024llm,
  author = {Pingchuan Ma and Tsun-Hsuan Wang and Minghao Guo and Zhiqing Sun and Joshua B. Tenenbaum and Daniela Rus and Chuang Gan and Wojciech Matusik},
  title = {{LLM and Simulation as Bilevel Optimizers: A New Paradigm to Advance Physical Scientific Discovery}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=hz8cFsdz7P},
}
Figure