TL;DR
Model-free reinforcement learning agents trained on multiple goals secretly learn an accurate model of their environment's physics. This paper introduces P-learning, a method to invert the Bellman equation and extract this hidden "world model," revealing that model-free agents possess surprising, latent zero-shot generalization capabilities.
What Problem Does This Paper Address?
Reinforcement learning (RL) is traditionally split into two separate paradigms:
- Model-free RL, where agents learn what actions to take based on rewards without understanding the underlying physics.
- Model-based RL, where agents explicitly learn a "world model" (how the environment transitions from state to state) to plan ahead.
Model-free agents are notoriously narrow—change the reward function slightly, and they usually have to relearn everything. This is due to the value equivalence problem: many completely different environment dynamics can yield the exact same optimal policy or value function ($Q$-values). Because model-free agents only learn what they value rather than what they understand, their internal knowledge has been historically viewed as uninterpretable and non-transferable.
This paper challenges this dichotomy by asking a fundamental question: When do model-free agents implicitly encode an accurate model of their environment?
Methods
The authors prove that if a value-based agent is trained on a sufficiently rich set of goals (Goal-Conditioned RL), the value equivalence problem breaks, forcing the agent to implicitly encode a unique and accurate world model.
To extract this hidden model, they introduce P-learning, an inverse analogue to Q-learning. While standard Q-learning holds the environment dynamics fixed and iteratively updates value estimates, P-learning holds the agent's learned $Q$-values, policies, and rewards fixed, and iteratively updates a candidate world model to make it mathematically consistent with the Bellman equation.
The authors provide rigorous theoretical guarantees across four regimes (deterministic/stochastic and finite/continuous state spaces), mapping out the exact number and distribution of goals required to perfectly reconstruct the environment's true transition kernel.
Datasets
The authors evaluate their approach on three standard RL benchmarks modified for goal-conditioning:
- FourRooms: A discrete gridworld benchmark tested across three levels of stochasticity (deterministic, windy, and teleporting).
- MuJoCo Reacher: A continuous, deterministic robotic arm environment.
- MountainCar: A continuous physics environment used to evaluate generalization across distinct state variables (position vs. velocity).
Key Insights and Ideas
- Value Equivalence is Fragile: You don't need infinite goals to understand the world. Training an agent on just a handful of diverse objectives provides enough mathematical constraints to uniquely pin down the true environment dynamics from model-free value functions.
- The "Local-Global" Hypothesis: Value-based agents trained to predict returns on a small number of local goals (e.g., reaching specific spatial positions) tend to implicitly encode an accurate world model over all dependent environment variables—including features the rewards never directly depended on, like velocity.
- Zero-Shot Planning via Extraction: Because the extracted implicit world model captures the true physics of the environment, you can drop a standard planning algorithm inside it to solve completely out-of-distribution (OOD) tasks zero-shot, without ever retraining the original model-free agent.
Key Results
- High-Fidelity Extraction: In the continuous Reacher environment, using an agent trained on just $|G| = 4$ position-based goals, P-learning extracted a world model with an incredibly low Normalized Mean Squared Error (NMSE) of $1.2 \times 10^{-4}$, even though the agent's underlying $Q$-values were coarsely approximated (NMSE = $0.57$).
- Performance Correlates with Understanding: The authors identified a powerful Spearman rank correlation ($\rho = -0.98$) between an agent's return and the accuracy of its internal world model. Higher network capacity and better model-free performance directly cause the agent to internalize a better model of the world.
- Superb Sample Efficiency: In the discrete FourRooms environment ($|S| = 68$), perfect or quasi-perfect world model recovery was achieved using a tiny fraction of candidate goals: just 1 goal for deterministic dynamics, 4 for windy dynamics, and roughly 20 for fully stochastic teleportation dynamics.
Limitations and Future Work
- Continuous Stochastic Limits: The theoretical proofs for stochastic continuous environments currently only apply to unconditional policies (where the agent's behavior doesn't change based on the goal). Extending this to goal-conditioned policies remains an open challenge.
- Algorithmic Scope: This framework is strictly limited to value-based agents that learn $Q$-values. It does not encompass pure policy gradient methods or partially observable Markov decision processes (POMDPs).
- Scale: While highly effective on standard continuous control tasks, P-learning has yet to be tested on massive, high-dimensional environments like Atari or complex 3D simulators.
- Future Outlook: The authors propose using P-learning as an interpretability or auditing tool, allowing researchers to "peek" inside a model-free agent's mind to see what it actually understands about safety and physics before deploying it in the real world.
Summary updated