Abstract
Traditional Preference-based Reinforcement Learning (PbRL) often requires thousands of human queries to learn complex, subjective tasks. We present In-Context Preference Learning (ICPL), a framework that leverages Large Language Models (LLMs) to iteratively refine reward functions expressed as Python code. By incorporating reward traces and historical differences into the LLM's context, ICPL achieves high performance with significantly reduced human effort, requiring up to 30x fewer queries than state-of-the-art baselines.
Introduction
Reinforcement Learning (RL) excels when reward functions are mathematically well-defined. However, defining rewards for human-centric behaviors—such as "graceful walking" or "human-like jumping"—is notoriously difficult. Preference-based RL (PbRL) addresses this by using human comparisons between agent behaviors. Despite its flexibility, traditional PbRL is often "tabula rasa," starting with zero knowledge and requiring extensive human feedback (1,500 to 15,000 queries) to converge. This high cost limits the practical application of PbRL in real-world scenarios.
Methodology: In-Context Preference Learning (ICPL)
ICPL reformulates preference learning as an iterative in-context optimization problem. Instead of training a black-box reward model, ICPL uses an LLM to generate and refine reward functions directly in Python code.
The ICPL loop consists of several key stages:
- Initialization: The LLM generates diverse candidate reward functions based on the environment context.
- RL Training: Agents are trained using these sampled reward functions.
- Preference Collection: Humans (or synthetic proxies) select the best and worst behaviors from rendered videos.
- Feedback Integration: The LLM receives the code for the selected behaviors, alongside "Reward Traces" (numerical histories of reward components) and "Historical Differences."
- Refinement: The LLM reasons about why certain rewards performed better and generates an improved iteration of the reward function.
The inclusion of the reward trace is critical; it allows the LLM to distinguish between rewards that were difficult to optimize and those that were fundamentally misaligned with the desired behavior.
Experimental Setup
The framework was evaluated across several benchmarks:
- IsaacGym Tasks: Nine physics simulations, including Ant, Humanoid, and complex robotic manipulation tasks like ShadowHand.
- HumanoidJump: A custom task designed for subjective evaluation of "human-like" jumping.
- Evaluation Metrics: Performance was measured against "Oracle" rewards and compared to traditional PbRL baselines like PEBBLE and SURF. Robustness was tested using both synthetic proxies and 27 human volunteers.
Results and Discussion
ICPL demonstrates a significant leap in query efficiency. On tasks like Ant and Humanoid, ICPL reached competitive performance levels with only approximately 50 human queries—a 30x reduction compared to traditional methods.
Key findings include:
- LLMs as Optimizers: LLMs can effectively reason about the relationship between reward code and physical agent behavior when provided with sufficient context.
- Subjective Alignment: In the HumanoidJump task, 85% of human evaluators preferred ICPL-trained agents over zero-shot baselines, indicating the method's ability to capture nuanced preferences.
- Comparison to Eureka: ICPL performs nearly as well as Eureka, a state-of-the-art method that utilizes ground-truth reward functions, despite ICPL relying only on sparse preference feedback.
Limitations and Future Work
While ICPL minimizes human effort, it remains computationally intensive. Each iteration requires training multiple RL policies from scratch, which can take hours. Future work may explore multimodal feedback, allowing humans to provide natural language critiques (e.g., "the robot is moving too fast") to further accelerate the optimization process.
Summary updated