Composing Value Functions in Reinforcement Learning

Benjamin van Niekerk, Steven James, Adam Christopher Earle, Benjamin RosmanICML 2019

This paper explores a fundamental challenge in artificial intelligence: compositionality. In a truly lifelong learning system, an agent shouldn't have to start from scratch every time it encounters a new task. Instead, it should be able to "plug and play" existing skills to solve new problems.

The authors provide a mathematical framework for doing exactly this—composing optimal value functions to solve the union of tasks without any additional training. They prove that in entropy-regularized Reinforcement Learning (RL) with deterministic dynamics, the optimal value function for a "union" of tasks (e.g., "do Task A OR Task B") is a simple, closed-form combination of the individual tasks' value functions. This allows an agent to solve new, complex tasks zero-shot by leveraging a library of previously learned skills.

The Challenge of Compositionality

In standard RL, agents are usually trained to maximize a specific reward function. If the goal changes slightly—for example, moving from "collect red apples" to "collect red apples OR green pears"—the agent typically requires significant retraining.

While humans can easily compose instructions ("Go to the kitchen AND get a snack"), RL agents struggle with this. Previous attempts at composition, like Linearly-solvable MDPs (LMDPs), were mathematically elegant but often restricted to simple, "tabular" environments where every state is known. This paper seeks to bring that compositional power to modern, high-dimensional RL (like deep Q-learning) where agents act based on raw pixels.

Methodology: Entropy-Regularized RL

The core of the paper lies in Entropy-Regularized RL. In this setting, the agent doesn't just maximize reward; it also tries to keep its policy close to a "reference" policy (usually a uniform random one) by minimizing Kullback-Leibler (KL) divergence.

Key Innovations

  1. Optimal "OR" Composition: The authors prove that if you have a library of optimal Q-functions ($Q^*_1, \dots, Q^*_m$) for different tasks, the optimal Q-function for a weighted union of those tasks is: $$Q^*_\tau(s, a) = \tau \log \left( \sum_{i=1}^m w_i \exp(Q^*_i(s, a) / \tau) \right)$$ This acts essentially as a "soft-max" over the existing skills.

  2. Deterministic Dynamics Assumption: The proof relies on the environment's transitions being deterministic. If the environment is stochastic, this specific composition is no longer strictly optimal, though it may still serve as a strong heuristic.

  3. Extension to Standard RL: By taking the "low-temperature limit" (letting the entropy penalty $\tau \to 0$), they show that in standard RL, the optimal composition for the union of tasks is simply taking the maximum: $Q^* \approx \max(Q^*_1, \dots, Q^*_m)$.
  4. Total-Reward Setting: Unlike many papers that focus on discounted rewards, this work proves convergence for "proper policies" in absorbing-state MDPs (tasks that eventually end), which is more natural for goal-oriented skills.

Experimental Setup

The authors evaluated their method in a custom high-dimensional video game environment.

Experimental environment and object variations
  • Input: 84x84 RGB pixel frames.
  • Environment: A grid-world-like layout with walls and various objects.
  • Objects: Six distinct items varying by color (Blue, Beige, Purple) and shape (Square, Circle).
  • Base Tasks: The agent was first trained on "base" tasks like Purple (collect any purple object) or BeigeSquare (collect the specific beige square) using deep Q-learning.

Key Insights and Results

The "aha moment" of this research is that while value functions aren't linear, the exponentiated value functions (often called "desirability functions") are. This allows for linear combinations of skills. Because the composition formula is closed-form, the agent can solve the "OR" task the very first time it sees it—achieving zero-shot success without needing to experience a single transition in the new task.

Visualization of a composed value function showing multiple peaks
  • Optimal Performance: In the video game domain, the composed Q-function for the PurpleOrBlue task achieved returns identical to an agent trained specifically on that task from scratch.
  • Multimodality: Visualizations of the value functions showed multiple "peaks" corresponding to different goals, demonstrating that the agent successfully maintained knowledge of all possible ways to satisfy the "OR" condition.
  • Linear Weighting: By adjusting the weights $w_i$ in the composition formula, the authors showed they could bias the agent toward specific objects (e.g., preferring circles over squares) without any retraining.
  • Temporal Composition: They demonstrated that an agent could solve a "collect all objects" task by greedily following the composed "OR" value function, effectively sequencing its skills over time.

Limitations and Future Work

The most significant limitation is the requirement for deterministic dynamics. In highly stochastic environments, the "OR" composition is only an approximation. Additionally, the current proof requires that tasks differ only in their rewards at terminal (absorbing) states. If tasks have different "running costs" or rewards scattered throughout the state space, the math becomes more complex.

Finally, while "OR" composition is exact under these constraints, "AND" composition (intersection of tasks) remains an approximation. Finding an optimal, closed-form solution for the intersection of tasks in high-dimensional spaces remains an open challenge for future research.

Summary updated

BibTeX
@inproceedings{niekerk2019composing,
  author = {Benjamin van Niekerk and Steven James and Adam Christopher Earle and Benjamin Rosman},
  title = {{Composing Value Functions in Reinforcement Learning}},
  booktitle = {International Conference on Machine Learning},
  year = {2019},
  url = {https://openreview.net/forum?id=BJVIVobdbB},
}
Figure