The Benefits of Model-Based Generalization in Reinforcement Learning

Kenny Young, Aditya Ramesh, Louis Kirsch, Jürgen Schmidhuber

Abstract

Model-Based Reinforcement Learning (RL) is widely believed to have the potential to improve sample efficiency by allowing an agent to synthesize large amounts of imagined experience. Experience Replay (ER) can be considered a simple kind of model, which has proved effective at improving the stability and efficiency of deep RL. In principle, a learned parametric model could improve on ER by generalizing from real experience to augment the dataset with additional plausible experience. However, given that learned value functions can also generalize, it is not immediately obvious why model generalization should be better. Here, we provide theoretical and empirical insight into when, and how, we can expect data generated by a learned model to be useful. First, we provide a simple theorem motivating how learning a model as an intermediate step can narrow down the set of possible value functions more than learning a value function directly from data using the Bellman equation. Second, we provide an illustrative example showing empirically how a similar effect occurs in a more concrete setting with neural network function approximation. Finally, we provide extensive experiments showing the benefit of model-based learning for online RL in environments with combinatorial complexity, but factored structure that allows a learned model to generalize. In these experiments, we take care to control for other factors in order to isolate, insofar as possible, the benefit of using experience generated by a learned model relative to ER alone.

Introduction

In deep reinforcement learning, Experience Replay (ER) is a standard mechanism for improving sample efficiency by reusing past transitions. While ER acts as a "perfect" non-parametric model of observed data, parametric world models offer the potential to generalize beyond seen states. This raises a fundamental question: Why should model-based generalization be superior to direct value-function generalization? If both the model and the value function are neural networks with similar capacities, it is not immediately obvious why learning the world's dynamics as an intermediate step is more effective than learning the value function directly from data.

Theoretical Motivation

The core hypothesis is that learning a model provides a stricter set of constraints on the hypothesis space of value functions. This is formalized through the concept of Model Consistency. While a model-free agent seeks a value function that satisfies the Bellman equation on observed transitions, a model-based agent requires the value function to be consistent with a learned model that generalizes across the state space.

Model consistency prunes the space of action-value functions more effectively than Bellman consistency alone.

As illustrated in Figure 1, the space of action-value functions consistent with a learned model is often a subset of those that merely obey Bellman optimality for the available data. By requiring the value function to align with the mechanics of a generalized model, the agent can more effectively "prune" incorrect value functions, leading to faster convergence toward the true value.

Experimental Framework

To test this theory, the researchers compared standard DQN (model-free with ER) against model-based agents using either simple feedforward networks or categorical latent-space models. The experiments focused on environments with "factored structure," where the dynamics of different state components are independent.

The structured environments used to evaluate model-based generalization: ProcMaze, ButtonGrid, and PanFlute.

The evaluation utilized four distinct environments:

  • ProcMaze: Procedurally generated mazes that require generalizing across different wall layouts.
  • ButtonGrid: A combinatorial task where the agent must toggle multiple buttons to receive a reward.
  • PanFlute: A highly sparse environment where specific sequences of "pipes" must be activated.
  • OpenGrid: A simple, unstructured grid world used as a negative control.

Results and Discussion

The Power of Factored Structure

In environments like ProcMaze and ButtonGrid, model-based agents achieved significantly higher returns than DQN with ER. Because these environments are factored, a model can learn the "rules" of the world (e.g., how a wall behaves) from one area and correctly predict outcomes in entirely new configurations. Conversely, in the unstructured OpenGrid, model-based approaches offered no advantage, as the model lacked structural patterns to exploit and essentially became a lossy version of the replay buffer.

Helpful Model Errors

In the PanFlute environment, a surprising phenomenon was observed: learned models actually outperformed the ground-truth model. This occurred because the learned models failed to perfectly capture the extreme sparseness of the reward, instead producing a "smoothed" reward signal. This approximation acted as a natural exploration heuristic, guiding the agent toward the goal more effectively than the true, sparse reward signal would have.

Combinatorial Scaling

As the complexity of the tasks increased—such as adding more buttons in ButtonGrid—the gap between model-based and model-free methods widened. Model-free agents often failed to learn as the state space grew combinatorially, while model-based agents maintained performance by leveraging their generalized understanding of the environment's mechanics.

Conclusion

The benefits of model-based RL are deeply tied to the environment's structure. By learning a model that captures factored dynamics, agents can narrow down the set of plausible value functions far more effectively than through the Bellman equation alone. While this advantage depends on the alignment between environment structure and model architecture, it provides a clear path toward more sample-efficient reinforcement learning in complex, structured domains.

Summary updated

BibTeX
@inproceedings{young2023benefits,
  author = {Kenny Young and Aditya Ramesh and Louis Kirsch and Jürgen Schmidhuber},
  title = {{The Benefits of Model-Based Generalization in Reinforcement Learning}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=Vue1ulwlPD},
}
Figure