TL;DR
This paper introduces a framework that uses Large Language Models (LLMs) to extract general, task-agnostic "background knowledge" about an environment to boost Reinforcement Learning (RL) efficiency. By converting LLM insights into potential-based reward shaping functions, the authors achieve significant sample efficiency gains across diverse tasks without sacrificing policy optimality.
What Problem Does This Paper Address?
Reinforcement Learning is notoriously sample-inefficient, often requiring millions of interactions to learn simple behaviors, especially in environments with sparse rewards. While recent research has used LLMs to provide "common-sense" guidance, these approaches are typically task-specific (e.g., prompting an LLM specifically for a "find the key" task).
This creates two problems:
- High Cost: Querying an LLM for every new task is expensive and slow.
- Lack of Generalization: Task-specific guidance doesn't help the agent understand the broader environment rules that apply across many different objectives.
The authors aim to extract background knowledge—general principles like "avoiding walls is good" or "collecting food is helpful"—that can be learned once and reused for many downstream tasks.
Methods
The authors propose a three-step framework:
- Data Collection: They use an exploration algorithm (RND) to collect a small, unlabeled dataset of environment interactions.
- Knowledge Extraction: They ground an LLM by showing it text captions of these trajectories and asking for feedback.
- Reward Shaping: This feedback is transformed into a potential function $\phi(s)$ used for Potential-Based Reward Shaping (PBRS). PBRS is a mathematically grounded technique that adds auxiliary rewards in a way that is guaranteed not to change the optimal policy of the original task.
They instantiate this via three variants:
- BK-CODE: The LLM writes Python code to calculate rewards based on state observations.
- BK-PREF: The LLM ranks pairs of trajectories. A neural network then learns a potential function that reflects these preferences.
- BK-GOAL: The LLM suggests potential goals the agent might want to reach. During RL, the agent receives auxiliary rewards for getting closer to these suggested goals.
Datasets
The framework was evaluated on two primary benchmarks:
- Minigrid (BabyAI domain): A grid-world environment where agents must navigate to objects or pick them up. The authors scaled these maps up to 30x30 to increase difficulty.
- Crafter: A 2D survival game inspired by Minecraft, requiring complex sequences of actions (mining, crafting, eating) to survive.
Crucially, for Minigrid, the authors tested generalization by excluding certain colors (purple) and objects (keys) from the data shown to the LLM, then testing the agent on tasks involving those unseen elements.
Key Insights and Ideas
- Interaction-Free LLM Use: Unlike methods that query LLMs during the RL loop, this framework extracts knowledge offline. This makes the training process much faster and cheaper.
- Task-Agnosticism is Key: By asking the LLM for general environment feedback rather than task-specific instructions, the resulting reward signals remain useful even when the agent's ultimate goal changes.
- Optimality Invariance: Because they use PBRS, even if the LLM provides slightly "noisy" or imperfect common-sense advice, the agent will still eventually converge to the true optimal solution defined by the environment's actual rewards.
- LLM Grounding: The paper demonstrates that LLMs perform better when "grounded" with actual environment trajectories (in text form) rather than just being given a manual or description.
Key Results
- Significant Speedup: In Minigrid tasks, the proposed methods reached high performance significantly faster than standard exploration baselines like RND or NovelD.
- Generalization to Unseen Tasks: The background knowledge proved robust. Agents trained with knowledge derived from "red ball" tasks were significantly more efficient at solving "purple key" tasks, even though the LLM hadn't seen those specific colors or objects in the grounding data.
- Scaling: The methods maintained high sample efficiency even as the map size increased from 20x20 to 30x30, whereas baseline performance dropped sharply.
- Model Sensitivity: While GPT-4 provided the best results, the BK-PREF and BK-GOAL variants were surprisingly robust when using smaller models like Llama-2-7B, whereas BK-CODE failed because smaller models struggle to write bug-free environment code.
Limitations and Future Work
- Prompt Engineering: The authors used relatively simple, modular prompts. They suggest that more sophisticated prompting techniques (like Chain-of-Thought) could further improve the quality of extracted knowledge.
- Manual Descriptions: The framework still requires a human-written text description of the environment and a way to caption trajectories. Automating this via vision-language models (VLMs) is a promising next step.
- Code Limitations: The BK-CODE variant currently cannot handle unstructured inputs like raw images, limiting its use in complex visual environments like Crafter.
Summary updated