TL;DR
Reinforcement learning in sparse-reward environments typically requires extensive trial-and-error, while manually engineering reward shaping functions demands significant expert effort. MEDIC solves this by pairing an off-the-shelf Large Language Model (LLM) with a lightweight, model-based feedback critic to solve a simplified, deterministic abstraction of the environment. The resulting LLM-generated plan is converted into a potential-based reward shaping function, dramatically cutting the sample complexity of training downstream agents (PPO and A2C) in stochastic, sparse-reward environments.
What Problem Does This Paper Address?
Model-free Reinforcement Learning (RL) is notoriously sample-inefficient when rewards are sparse and state transitions are stochastic. A classic remedy is reward shaping—providing intrinsic reward bonuses that guide exploration toward the goal. Under Potential-Based Reward Shaping (PBRS), this can be done without altering the optimal policy. However, designing effective potential functions traditionally requires domain experts to hand-craft heuristics or record demonstrations for Inverse RL, both of which are time-consuming and prone to human bias.
While LLMs possess broad commonsense priors, they struggle with multi-step deterministic planning and spatial reasoning, often generating invalid actions or hallucinating transitions when prompted directly. This paper investigates: Can we reliably guide off-the-shelf LLMs to solve a relaxed version of an environment, and use that solution to construct automated reward shaping for RL agents?
Methods
The authors introduce MEDIC (Model-based feEDback critIC), an LLM-modulo framework structured as follows:
Deterministic Abstraction (M')
│
▼
LLM + MEDIC Critic ──► Valid Guide Plan (π_LLM)
│
▼
Potential-Based Reward Shaping
│
▼
Stochastic Sparse RL (M)
- Problem Abstraction: Rather than tasking the LLM with handling the full stochastic Markov Decision Process (MDP), the system constructs a deterministic abstraction ($M'$).
- LLM Interaction with Model-Based Critic (MEDIC):
- At each step, the LLM receives a prompt containing the Task Description (e.g., "use key to open door and reach goal"), an Observation Description (a symbolic text representation of the agent's local field of view), and a Query Description.
- A lightweight, rules-based environment critic checks whether the LLM's proposed action is physically valid given the current state.
- If an action is invalid (e.g., attempting to move forward into a locked door or pick up a key when not facing it), MEDIC intercepts execution, records the invalid choice, and generates a back-prompt listing feasible actions. The LLM re-samples until it produces a valid step.
- Potential-Based Reward Shaping (PBRS):
- The successful trajectory $\tau_g \sim \pi_{\text{LLM}}$ is mapped into a potential-based intrinsic reward.
- During the RL exploration phase, transitions matching the LLM plan receive uniformly increasing intrinsic reward increments (summing to +1 at the goal).
- Downstream Training: Standard on-policy RL algorithms (PPO and A2C) train on the original stochastic, sparse-reward MDP using the augmented replay buffer.
Datasets
The authors evaluate on gridworld environments from the BabyAI benchmark (built on MiniGrid):
- DoorKey (5×5 with 3 layouts, and 6×6): Requires multi-stage sub-goals—locating a key, picking it up, unlocking a door, and navigating to the terminal square.
- Empty-Random (5×5): An obstacle-free environment with randomized starting positions for every episode.
- LavaGap (5×5): Requires navigating past lethal obstacle tiles (lava) where stepping into lava terminates the episode immediately.
No new external datasets were collected; experiments evaluate procedural MiniGrid generation using OpenAI's gpt-3.5-turbo for planning.
Key Insights and Ideas
- Verification over Generation: LLMs do not need to be autonomous, end-to-end planners. Offloading action precondition verification to a deterministic critic eliminates hallucinations while still exploiting the LLM’s high-level procedural common sense (e.g., keys precede doors).
- Direct Prompting Fails Completely: Zero-shot and step-by-step LLMs without an external verifier produce 0% valid plans on these tasks. Adding interactive back-prompting converts a 0% success rate into 100%.
- Sub-optimal Plans Are Sufficient for Guidance: The LLM's plan does not have to be mathematically optimal. Even slightly winding plans offer a strong directional gradient for exploration, bypassing the "sparse reward desert."
- Progressive Potential Matters: Ablations reveal that shaping rewards with linearly increasing potentials across the plan performs substantially better than uniform, flat reward distribution along the trajectory.
Key Results
- Plan Generation (RQ1):
- Direct LLM Prompting: 0% success rate across all environments.
- LLM + MEDIC (Ours): 100% task success rate across all environments.
- Efficiency: Generating the guide plan requires $\le 30$ environment step queries and at most 10 back-prompts per step, whereas training a raw RL agent to find the initial policy requires $10^5$ steps.
- Plan Quality: In
DoorKey-5x5, MEDIC yields an average plan length of $15.2 \pm 6.57$ (optimal A* search is 11) with average reward $0.945 \pm 0.02$ (optimal is $0.96$). - RL Sample Efficiency Boost (RQ2):
- When training PPO and A2C on stochastic environments, MEDIC-guided reward shaping significantly accelerates policy convergence compared to vanilla RL and text-augmented baselines.
- In the scaled-up
DoorKey-6x6environment, LLM-guided shaping improves sample efficiency by approximately 29% for PPO and 52% for A2C.
Limitations and Future Work
- Reliance on Domain Preconditions: Constructing the model-based critic assumes known action preconditions and environment geometry to validate actions.
- Textual Grid Representations: Describing 2D/3D visual and spatial information textually to LLMs remains fragile and limits scaling to complex observation spaces.
- Discarding Partial Plans: If the LLM exceeds prompt budgets or fails without MEDIC, partially correct plans are currently discarded. Leveraging partially correct rollouts effectively is left to future work.
- Scalability: Experiments focus on small, discrete gridworlds (up to 6×6); testing on high-dimensional continuous control or complex simulated robotics remains open.
Summary updated