Beyond Human Preferences: Exploring Reinforcement Learning Trajectory Evaluation and Improvement through LLMs

Zichao Shen, Tianchen Zhu, Qingyun Sun, Shiqi Gao, Jianxin LiarXiv 2024 · DOI

Abstract

Designing effective reward functions remains a significant hurdle in Reinforcement Learning (RL), often leading to sparse feedback or unintended "reward hacking." While Preference-based Reinforcement Learning (PbRL) mitigates these issues by using human rankings of agent trajectories, the approach is limited by the high cost and low speed of human intervention. This paper introduces LLM4PG, a framework that automates the preference generation process using Large Language Models (LLMs). By translating agent trajectories into natural language descriptions, LLM4PG allows LLMs to act as zero-shot experts, ranking performance based on complex linguistic instructions. Our results demonstrate that LLM4PG significantly accelerates convergence and improves constraint satisfaction in grid-world environments compared to traditional reward engineering.

Introduction

Reinforcement Learning (RL) agents typically rely on mathematical reward signals to learn optimal behaviors. However, crafting these signals is notoriously difficult. Sparse rewards can leave agents wandering aimlessly, while poorly designed functions may encourage agents to exploit loopholes. Preference-based RL (PbRL) was developed to align agent behavior with human intent through comparative rankings, but the human-in-the-loop requirement creates a scalability bottleneck.

LLM4PG addresses this by leveraging the reasoning capabilities of LLMs to evaluate and rank trajectories described in text. This allows for high-quality, automated reward shaping that can incorporate complex, natural language constraints without the need for manual reward engineering.

Methodology

The LLM4PG framework operates through a four-stage pipeline designed to bridge the gap between raw environment data and high-level reasoning.

  1. Language Interpreter for State Abstraction: Raw trajectory data (sequences of states and actions) is converted into a structured text description. This summary includes the goal status, step count, key events (e.g., "broke a vase"), and any specific constraints encountered.
  2. Preference Generation via LLM: Two trajectory descriptions are presented to an LLM (such as Mixtral 8x7B or Qwen-max). Given the task objectives and constraints in plain English, the LLM determines which trajectory is superior.
  3. Reward Modeling: The preferences generated by the LLM are used to train a compact neural network, the reward predictor. This model learns to map trajectories to numerical values, effectively distilling the LLM's logic into a computationally efficient signal.
  4. Policy Optimization: A standard RL algorithm, such as Proximal Policy Optimization (PPO), uses the rewards from the predictor to train the agent's policy. The agent optimizes its behavior based solely on the LLM-derived reward signal.
Overview of the LLM4PG framework, illustrating the pipeline from trajectory abstraction to policy optimization.

Experimental Setup

The framework was evaluated using the MiniGrid environment, focusing on tasks with varying complexity:

  • MiniGrid-Unlock-v0: Requires the agent to find a key and unlock a door.
  • MiniGrid-LavaGapS7-v0: A high-stakes navigation task where the agent must cross a gap in a lava strip.
  • Linguistic Constraints: The authors introduced arbitrary rules, such as requiring the agent to "drop the key exactly three times" before opening the door, to test the LLM's ability to enforce non-trivial behavioral constraints.

Key Results and Discussion

LLM4PG demonstrated significant performance gains across several metrics:

  • Accelerated Convergence: In the "Unlock" task, agents trained with LLM4PG converged in approximately 50,000 steps, representing a 2x speedup over agents using the original environment reward (which required over 100,000 steps).
  • Effective Constraint Satisfaction: When tasked with specific linguistic constraints (e.g., dropping a key three times), LLM4PG outperformed standard methods like Lagrange PPO. It achieved higher task rewards while adhering more strictly to the provided rules.
  • Overcoming Sparse Rewards: In environments like LavaGap, where agents often fail to receive any reward from the environment, the LLM provided "denser" feedback by ranking near-misses higher than total failures, facilitating a smoother learning gradient.
Success rate comparison in the Unlock task, showing LLM4PG (llm_reward_predictor) converging significantly faster than the original reward.

Limitations and Future Work

While promising, LLM4PG currently relies on episodic rewards, where the predictor evaluates an entire trajectory at once. Future iterations could benefit from step-level rewards to provide more granular feedback for long-horizon tasks. Additionally, the system's performance is tied to the accuracy of the "Language Interpreter." The authors suggest that moving toward multimodal LLMs (e.g., GPT-4o) could allow the system to evaluate visual frames directly, bypassing the need for text-based state abstraction.

Conclusion

LLM4PG represents a step toward more intuitive and scalable RL training. By using LLMs as proxy experts, researchers can "program" agent behavior through natural language, significantly reducing the effort required for reward engineering while improving the agent's ability to handle complex, human-centric constraints.

Summary updated

BibTeX
@misc{shen2024beyond,
  author = {Zichao Shen and Tianchen Zhu and Qingyun Sun and Shiqi Gao and Jianxin Li},
  title = {{Beyond Human Preferences: Exploring Reinforcement Learning Trajectory Evaluation and Improvement through LLMs}},
  year = {2024},
  eprint = {2406.19644},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.19644},
}
Figure