NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Synthesizing Programmatic Reinforcement Learning Policies with Large Language Model Guided Search

Max Liu, Chan-Hung Yu, Wei-Hsu Lee, Cheng-Wei Hung, Yen-Chun Chen, Shao-Hua Sun

TL;DR

Researchers have developed LLM-GS, a framework that uses Large Language Models to jumpstart the search for programmatic reinforcement learning policies. By having LLMs write "Pythonic" code that is then translated into domain-specific languages and refined via a novel Scheduled Hill Climbing algorithm, the system achieves optimal performance with a fraction of the environment interactions required by previous state-of-the-art methods.

What Problem Does This Paper Address?

Reinforcement Learning (RL) has achieved incredible feats, but most policies are "black boxes"—deep neural networks that are nearly impossible for a human to audit or understand. Programmatic Reinforcement Learning (PRL) offers an alternative: representing a policy as a human-readable program (code). This makes policies interpretable, verifiable, and better at generalizing to new scenarios.

The catch? Searching for the right "program" in a sea of possible code combinations is computationally brutal. Current PRL methods often require tens of millions of interactions with an environment just to find a simple working script. Furthermore, LLMs—which are great at coding—struggle with the niche Domain-Specific Languages (DSLs) used in RL environments because those languages weren't well-represented in their training data.

Karel Domain DSL Grammar

Methods

The authors introduce the LLM-Guided Search (LLM-GS) framework, which consists of three clever components:

  1. Pythonic-DSL Strategy: Instead of asking an LLM to write obscure DSL code directly, they instruct it to write restricted Python. Since LLMs are "fluent" in Python, they produce much more logically sound scripts. A simple compiler then translates this Python into the target DSL.
  2. Domain and Task-Aware Prompting: They provide the LLM with a "scaffolding" prompt that describes the environment's physics and the specific task goals in natural language, allowing the LLM to use its common-sense reasoning to "prune" the search space.
  3. Scheduled Hill Climbing (Scheduled HC): Once the LLM provides a decent starting program, the system needs to fine-tune it. Standard Hill Climbing searches a fixed number of "neighbor" programs. Scheduled HC uses a sinusoidal scheduler to start with a small search budget (trusting the LLM's initial guess) and gradually increases the exploration breadth as the search progresses.

Datasets

The framework was evaluated on several challenging benchmarks:

  • Karel Domain: A classic "robot in a grid" environment.
  • Karel-Hard: A more difficult set of tasks (like DoorKey) where the agent must find a key in one room to unlock a door to another.
  • Novel Tasks: The authors introduced PathFollow and WallAvoider to test if the system could handle tasks described only in natural language.
  • MiniGrid: A diverse grid-world environment used to prove the framework can adapt to different domains beyond Karel.
The DoorKey Task in Karel-Hard

Key Insights and Ideas

  • The "Human Interest" Prior: The authors argue that while the space of all possible programs is infinite, the space of programs humans actually care about is small. LLMs act as a repository of "human civilization's text projection," providing a massive head start by guessing programs that make sense to us.
  • Python as a Lingua Franca: The "aha moment" here is realizing that an LLM's failure to write a specific DSL isn't a lack of logic, but a lack of vocabulary. By using Python as an intermediate step, they unlock the LLM's full reasoning potential.
  • Efficiency through Trust: By starting with a small search budget in Scheduled HC, the algorithm avoids wasting millions of samples early on when the LLM-provided initialization is already "warm."

Key Results

  • Massive Efficiency Gains: In the difficult DoorKey task, previous state-of-the-art methods failed to converge even after 1 million interactions. LLM-GS found the optimal solution in roughly 500,000 interactions.
  • Higher Code Quality: The Pythonic-DSL strategy achieved a significantly higher "acceptance rate" (grammatically correct, executable code) across 9 out of 10 tasks compared to direct DSL generation.
  • Zero-Shot Task Solving: For the novel tasks, LLM-GS enabled users with no programming or DSL knowledge to generate high-performing policies simply by describing the goal in plain English.
  • Statistical Superiority: LLM-GS statistically outperformed standard Hill Climbing on 8 out of 10 tasks by the end of the search process.

Limitations and Future Work

  • The "Expert" Requirement: While the task prompts are easy for anyone to write, the system prompt (defining the DSL-to-Python mapping) still requires a domain expert who understands the environment's underlying grammar.
  • LLM Dependency: The framework relies on high-quality, closed-source models like GPT-4. The authors note that the availability and cost of these models are a factor.
  • Low-Level Control: The current framework is designed for high-level logic (grid navigation, object manipulation). Adapting it to low-level continuous control (like motor torque for a walking robot) remains a significant challenge for future research.

Summary updated

BibTeX
@inproceedings{liu2025synthesizing,
  author = {Max Liu and Chan-Hung Yu and Wei-Hsu Lee and Cheng-Wei Hung and Yen-Chun Chen and Shao-Hua Sun},
  title = {{Synthesizing Programmatic Reinforcement Learning Policies with Large Language Model Guided Search}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=8DBTq09LgN},
}
Figure