Entropy-Regularized Token-Level Policy Optimization for Large Language Models

Muning Wen, Cheng Deng, Jun Wang, Weinan Zhang, Ying Wen · DOI

TL;DR

This paper introduces ETPO, a novel reinforcement learning (RL) approach that optimizes Large Language Models (LLMs) at the token level for interactive tasks. By decomposing the learning process and reward signals to individual tokens, ETPO addresses instability issues and improves credit assignment, leading to better performance in complex decision-making scenarios like code generation.

What Problem Does This Paper Address?

Large Language Models (LLMs) show great potential as intelligent agents, but traditional methods for enhancing their interactive decision-making capabilities often rely on extensive prompt engineering, curated examples, or complex reward models. Reinforcement learning (RL) offers a more dynamic alternative, allowing LLMs to learn directly from interaction. However, applying RL to LLMs faces two major challenges:

  1. Action Space Explosion and Instability: LLM actions are sequences of tokens, leading to an astronomically large action space. This makes exploration difficult and can cause instability during RL fine-tuning.
  2. Credit Assignment Mismatch: RL typically assigns rewards at the action level, which are sparse for token sequences. This makes it hard to credit individual tokens for their contribution to the overall success or failure, creating a disconnect between maximizing task rewards and preserving the LLM's natural language modeling capabilities.

Methods

The paper proposes Entropy-Regularized Token-Level Policy Optimization (ETPO), an RL algorithm designed to tackle these challenges. Key components include:

  • Entropy Regularization: ETPO uses an entropy-regularized reinforcement learning (ERL) framework. This helps balance exploration with exploitation and constrains the LLM's policy to stay close to its original language modeling distribution, preventing it from deviating too much and losing coherence.
  • Per-Token Soft Bellman Update: This is the core innovation. Instead of updating the Q-function (which estimates the value of taking an action) at the entire action (token sequence) level, ETPO decomposes this update to operate on each token individually. This allows for more granular credit assignment and makes the update process more consistent with language modeling principles.
  • Per-Token Policy Update: Following the per-token Q-function update, ETPO also updates the LLM's policy at the token level. This ensures that the policy learns to generate tokens that contribute to higher expected rewards while still adhering to the learned token-level Q-values.
  • Theoretical Consistency: The authors provide theoretical proofs demonstrating that their per-token updates are consistent with traditional action-level updates, ensuring that the optimization process remains sound.
  • Linear Complexity in Action Exploration: This token-level decomposition reduces the computational complexity of action exploration from exponential to linear with respect to the action length, significantly improving stability and efficiency.

Datasets

The experiments were conducted using a simulated environment for data science code generation. The datasets used for evaluation include:

  • Kaggle Datasets: Pharyngitis, Kidney Stone, Health Insurance, Spaceship Titanic.
  • OpenML Datasets: Airlines, Balance Scale, Breast-W, CMC, Credit-G, Diabetes, Eucalyptus, Jungle Chess, PC1, Tic-Tac-Toe.

These datasets are used to train and evaluate LLM agents on tasks like classification.

Key Insights and Ideas

  • Token-level optimization is crucial for LLMs: Directly applying action-level RL to LLMs is problematic due to the vast action space and sparse rewards. Optimizing at the token level offers a more natural and effective way to fine-tune LLMs for interactive tasks.
  • Decomposition bridges the gap between RL and language modeling: By breaking down the Q-function and policy updates into token-level operations, ETPO harmonizes the goals of maximizing rewards with preserving the LLM's inherent language modeling capabilities.
  • Per-token credit assignment leads to stability and performance: The granular credit assignment allows for more stable learning and better performance, especially in multi-step decision-making scenarios where individual token choices have cumulative effects.
  • "Hallucinations" can be a source of creativity: The paper observes that RL-trained models sometimes deviate from prompts to achieve higher rewards. This "hallucination" is reframed not as an error to be avoided, but as a potential source of innovation and emergent capabilities, which can be harnessed through exploration-exploitation mechanisms.

Key Results

  • Performance Improvement: ETPO significantly improves the performance of the CodeLlama-7B model on data science code generation tasks, achieving higher ROC AUC scores compared to baselines.
  • Superiority over Baselines: ETPO outperforms a variant PPO baseline inherited from RLHF and a "Reflection" baseline (which uses the LLM without RL training) across most datasets. For example, on the Balance Scale dataset, ETPO achieved a ROC AUC score of 0.9289, compared to 0.8833 for the vanilla CodeLlama-7B.
  • Convergence: The paper shows that ETPO exhibits stable convergence, with its performance improving more gently and consistently than action-level PPO, which can suffer from instability in later stages.
  • Minimal Impact on Language Modeling: Ablation studies show that ETPO has a relatively small impact on the original language modeling capabilities (perplexity) of the LLM, indicating that it enhances performance without sacrificing fundamental language understanding.

Limitations and Future Work

  • Requirement for Quantitative Rewards: A limitation acknowledged is the need for a quantitative reward function, which can be challenging to obtain in some purely textual environments.
  • Future Work: The authors suggest integrating ETPO with self-rewarding mechanisms or hindsight relabeling techniques to address the reward function limitation and further explore its potential for fostering emergent capabilities and creativity in LLM agents.

Summary updated

BibTeX
@misc{wen2024entropy,
  author = {Muning Wen and Cheng Deng and Jun Wang and Weinan Zhang and Ying Wen},
  title = {{Entropy-Regularized Token-Level Policy Optimization for Large Language Models}},
  year = {2024},
  eprint = {2402.06700},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.06700},
}
Figure