Towards Unraveling and Improving Generalization in World Models

Qiaoyi Fang, Weiyu Du, Hang Wang, Junshan Zhang · Submission to NeurIPS 2024 · Rejected

TL;DR

This paper investigates how latent representation errors impact the generalization of visual world models (like Dreamer) using a continuous-time stochastic differential equation (SDE) framework. It reveals that zero-drift representation errors provide beneficial implicit regularization, but non-zero drift introduces destabilizing bias and compounding rollout errors—issues that can be effectively mitigated by regularizing the model's input-output Jacobian norm.

What Problem Does This Paper Address?

World models have emerged as state-of-the-art architectures in visual model-based reinforcement learning (RL), enabling agents to learn compact latent environment dynamics from pixels and optimize policies entirely in imagination. Despite impressive empirical success across complex domains, it remains poorly understood why and when world models generalize well to unseen states.

A central question is how representation errors in the learned latent space affect generalization: does imperfect latent encoding hurt performance, or could it paradoxically act as a regularizer? Furthermore, when errors accumulate across multi-step predictive rollouts, how can we prevent dynamics models from drifting and failing over longer planning horizons?

Methods

  1. Continuous-Time SDE Formulation: The authors model the discrete components of world models (encoder, sequence model, transition predictor, decoder) as a coupled system of stochastic differential equations with an error perturbation parameter $\varepsilon$.
  2. Perturbation Analysis of Representation Errors:
  3. Zero-Drift Errors: When errors have zero drift (pure stochastic diffusion), second-order perturbation analysis reveals an explicit Hessian-dependent regularization term $\mathcal{S} \succeq 0$. This acts as implicit regularization, favoring flatter, wider minima in the loss landscape.
  4. Non-Zero-Drift Errors: Real-world encoder errors are typically biased (non-zero drift). The authors show this introduces an extra bias term $\tilde{\mathcal{R}}$ that degrades implicit regularization and destabilizes training.
  5. Approximation Bound for CNN Encoder-Decoders: Under a manifold assumption, the paper establishes theoretical bounds on the Wasserstein-1 ($W_1$) representation error of CNN architectures, justifying treating $\varepsilon$ as a small perturbation.
  6. Jacobian Regularization: Because the destabilizing drift and trajectory divergence bounds scale with the Frobenius norm of the dynamics model's input-output Jacobian, the authors propose augmenting the dynamics loss with a Jacobian penalty: $$\bar{\mathcal{L}}_{\text{dyn}} = \mathcal{L}_{\text{dyn}} + \lambda \|J_\theta\|_F$$ To maintain computational efficiency, $\|J_\theta\|_F$ is approximated using a single random projection.

Datasets

The authors evaluate their method on continuous visual control benchmarks from MuJoCo (specifically, Walker and Quadruped) built upon a DreamerV2 baseline. No new datasets were introduced, but the authors designed several zero-shot visual perturbation suites to evaluate out-of-distribution generalization:

  • Full-image Gaussian noise ($\mathcal{N}(\mu, \sigma^2)$ across varying variances $\sigma^2 \in [0.05, 0.55]$).
  • Image rotation ($\alpha \in \{20^\circ, 30^\circ\}$).
  • Random spatial masking with Gaussian noise ($\beta\% \in [25\%, 75\%]$ masked).

Key Insights and Ideas

  • Modest Latent Errors Are a Feature, Not a Bug: Just as moderate batch sizes (16 or 32) empirically outperform very large or very small batches, moderate zero-drift representation noise acts as implicit regularization, promoting wider loss minima and better test-time robustness.
  • Drift is the Enemy: Unlike standard noise-injection literature where perturbations are zero-mean Gaussian, real encoder errors exhibit non-zero drift that compounds across time steps.
  • Controlling Error Propagation via Jacobians: State divergence in imagination rollouts scales exponentially with the dynamics model's Jacobian norms. Penalizing the Jacobian restricts how fast initial encoder errors can blow up during extended rollouts.

Key Results

  • Generalization Under Visual Perturbations: Across Walker and Quadruped, Jacobian regularization consistently outperformed vanilla DreamerV2 on unseen perturbed states. For instance, under severe rotation ($\alpha = 30^\circ$), reward on Quadruped jumped from 389.41 (baseline) to 610.53 (with Jacobian regularization). Under 75% image masking, Walker reward improved from 446.74 to 685.49.
  • Robustness Against Injected Latent Drift: When synthetic non-zero drift noise was injected during training, vanilla models collapsed or degraded severely (e.g., Quadruped baseline scored only 32.87 at 2M steps), while the Jacobian-regularized model maintained high returns (958.7).
  • Faster Convergence on Extended Horizons: Extending the Walker rollout horizon from 50 to 100 steps usually degrades planning accuracy. With Jacobian regularization ($\lambda = 0.05$), the agent converged to high reward (~936) roughly 100,000 steps faster than the baseline.

Limitations and Future Work

  • Simplified Loss Formulation: The theoretical derivation treats the loss function deterministically w.r.t. state variables, whereas practical world models optimize densities via variational bounds (KL divergences). The authors note that a full PDE treatment based on the Kolmogorov forward equation remains future work.
  • Scope of Evaluated Environments: Experiments were limited to MuJoCo locomotion tasks (Walker and Quadruped). Validation on higher-dimensional, visually richer domains (e.g., Minecraft, Atari, or real-world autonomous driving) is needed.
  • First-Order Jacobian Approximation: While using a single random projection enables tractability, more accurate or adaptive estimation of high-dimensional Jacobians could further stabilize optimization.

Summary updated

Abstract

World model has recently emerged as a promising approach to reinforcement learning (RL), as evidenced by its great successes that world model based agents exhibit state-of-the-art performance on a wide range visual control tasks. In this study, we aim to first obtain a clear understanding of the generalization capability of world models by examining the impact of _latent representation error_, and then devise new methods to enhance its generalization. We hypothesize that latent representation errors may paradoxically bring generalization to the model. We develop a continuous-time stochastic dynamics framework to quantify the impact of these errors, by examining the regularization effects for both cases with zero-drift representation errors and non-zero-drift representation errors. We propose a Jacobian regularization scheme to mitigate the "destabilizing'' effects of non-zero drift errors, thereby enhancing training stability and model generalization. Our empirical results confirm that this regularization approach not only stabilizes training but also accelerates convergence and improves performance on long-horizon prediction.
BibTeX
@misc{fang2025towards,
  author = {Qiaoyi Fang and Weiyu Du and Hang Wang and Junshan Zhang},
  title = {{Towards Unraveling and Improving Generalization in World Models}},
  year = {2025},
  eprint = {2501.00195},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.00195},
}
Figure