Abstract
A long-standing goal of reinforcement learning is to develop algorithms that can learn on training tasks and generalize to unseen tasks, much like humans. This is particularly challenging when tasks share similar dynamics but have different reward functions. We present a novel metric, Task Distribution Relevance (TDR), which uses optimal Q-functions to quantitatively measure task similarities. We demonstrate that standard Markovian policies are sub-optimal for task distributions with high TDR. To address this, we propose the Task Aware Dreamer (TAD) framework, utilizing Reward-Informed World Models (RIWM). TAD captures invariant latent features and encodes historical reward signals into policies to distinguish between tasks. Extensive experiments in the DeepMind Control Suite show that TAD significantly improves multi-task performance and generalizes effectively to unseen tasks.
Introduction
Deep Reinforcement Learning (DRL) agents are often highly specialized, failing when transition dynamics are constant but goals (reward functions) change. For example, an agent trained to run forward may fail to flip backward despite the physical environment being identical. The challenge lies in the agent's inability to distinguish the current task context without historical information, specifically reward signals.
This work addresses the task-distribution setting where transition dynamics are shared across tasks. We identify that standard policies—even those with state-action history—are mathematically sub-optimal if they ignore historical rewards. By incorporating these signals, we can build "generalist" agents capable of zero-shot generalization to new goals within the same physical world.
Theoretical Foundation: Task Distribution Relevance (TDR)
A core contribution of this work is the Task Distribution Relevance (TDR) metric. TDR quantifies how much optimal actions differ across tasks for the same state.
- Low TDR: Tasks are similar; the same action is often optimal across different goals (e.g., balancing a pole vs. balancing it with sparse rewards).
- High TDR: Tasks are diametrically opposed; optimal actions for one task may be detrimental to another (e.g., running forward vs. running backward).
Our theoretical analysis proves that in high-TDR environments, policies that do not account for historical rewards essentially play an "average" version of all tasks, leading to poor performance.
Methodology: The Task Aware Dreamer (TAD)
To overcome the limitations of standard world models, we introduce the Task Aware Dreamer (TAD), which implements Reward-Informed World Models (RIWM).
Reward-Informed World Models (RIWM)
Unlike standard models that focus solely on state and observation prediction, RIWM explicitly incorporates historical reward signals into the latent state $h_t$. It includes a dedicated Task Model $p(\mathcal{M}|h_t, s_t)$ to infer the current task context from the agent's history. This allows the agent to "identify" which task it is currently performing based on the rewards it has received.
Task Context Loss
To ensure the world model effectively differentiates between tasks, we introduce a novel task context loss ($L_{task}$). We propose two variants:
- TAD-CE: Employs a cross-entropy loss to classify the task index.
- TAD-SC: Uses a supervised contrastive loss to cluster embeddings of the same task together while pushing different tasks apart in the latent space.
Experimental Evaluation
We evaluated TAD against state-of-the-art baselines, including CURL, SAC+AE, Dreamer, and MAMBA, across several continuous control benchmarks in the DeepMind Control Suite (DMC) and MuJoCo.
Key Results
- Handling High TDR: In complex task sets like Cheetah-run & flip, TAD-SC achieved a score of 588.8, significantly outperforming the next best baseline, MAMBA (375.6), and standard Dreamer (241.1).
- Zero-Shot Generalization: In target velocity tasks (Cheetah_speed), TAD achieved test scores of ~909, whereas standard Dreamer failed to generalize (score ~3).
- Latent Separation: Qualitative t-SNE visualizations (not shown) confirm that TAD successfully clusters different tasks into distinct latent regions, whereas standard models produce overlapping, indistinguishable representations.
Conclusion
The Task Aware Dreamer demonstrates that historical reward signals are the "missing link" for task identification in reinforcement learning. By integrating these signals into a world model framework and utilizing the TDR metric to understand task difficulty, TAD achieves superior zero-shot generalization. Future work will explore environments where both rewards and dynamics vary simultaneously, further pushing the boundaries of generalist robotic agents.
Summary updated