TL;DR
The paper introduces T2MIR (Token- and Task-wise MoE for In-context RL), a novel framework that integrates the Mixture-of-Experts (MoE) architecture into transformer-based decision models. By deploying parallel token-wise and task-wise MoE layers, T2MIR successfully addresses the challenges of multi-modal data streams and task heterogeneity, significantly boosting the adaptation speed and performance of reinforcement learning agents on unseen tasks.
What Problem Does This Paper Address?
In-Context Reinforcement Learning (ICRL) allows an agent to adapt to new downstream tasks purely through prompt conditioning (using past experiences as context) without updating its model weights. While promising, ICRL faces two major bottlenecks:
- Intrinsic Multi-Modality: Unlike language models that process uniform text tokens, ICRL models must digest sequences of states (continuous physical quantities or images), actions (high-frequency control signals), and rewards (sparse scalars). These modalities possess vastly different semantic structures.
- Task Diversity and Heterogeneity: Training a single model across highly diverse tasks often triggers gradient conflicts. For example, two navigation tasks with opposite destination goals will demand completely contrary actions under the identical state, causing opposing gradients that stall the learning process.
Methods
To overcome these challenges, the authors propose T2MIR, which replaces the standard feedforward network (FFN) in transformer blocks with two parallel MoE layers:
- Token-wise MoE: This layer automatically routes individual tokens to specialized experts based on their modality (state, action, or reward). To prevent all tokens from collapsing onto a few favorite experts, the authors incorporate load-balancing and importance regularization losses.
- Task-wise MoE: This layer uses sparse routing to assign diverse tasks to specialized task-level experts, effectively isolating distinct task behaviors and mitigating gradient conflicts.
To make task routing more precise, the authors introduce a contrastive learning method (InfoNCE loss). It maximizes the mutual information between a task and its router representation, ensuring the model captures task-relevant features while remaining invariant to behavior policies. The outputs of both MoE components are concatenated and passed to the next transformer layer.
T2MIR is highly flexible and was successfully implemented on top of two mainstream ICRL backbones: Algorithm Distillation (T2MIR-AD) and Decision-Pretrained Transformer (T2MIR-DPT).
Datasets
The framework was evaluated across several multi-task reinforcement learning benchmarks using offline datasets of varying qualities (Mixed, Medium-Expert, and Medium):
- DarkRoom: A discrete grid-world environment with multiple goals.
- Point-Robot: A 2D navigation environment.
- MuJoCo Locomotion: Cheetah-Vel (running at target velocities) and Walker-Param (locomotion with randomized physical parameters like friction and mass).
- Meta-World: Robotic manipulation tasks (Reach and Push).
- Ant-Dir & ML10: Evaluated in the appendix to test scalability on harder task suites.
Key Insights and Ideas
- Natural Modality Clustering: t-SNE visualizations revealed that the token-wise MoE naturally segregates tokens by their semantic modality (states, actions, rewards) into distinct expert clusters without manual labeling.
- Task Space Separation: The task-wise MoE successfully maps similar tasks closely together and separates distinct ones based on task parameters (like target velocity), as seen in the visualization below.
- Gradient Conflict Resolution: By routing conflicting tasks to different experts, T2MIR maintains nearly orthogonal gradients across diverse tasks, preventing opposing objectives from canceling each other out during training.
- Backbone Synergy: Ablation studies showed that the token-wise MoE is more vital for the AD backbone (which handles long historical contexts), whereas the task-wise MoE is more critical for the DPT backbone (which relies on short, precise task prompts).
Key Results
T2MIR consistently outperformed strong baselines (including vanilla AD, DPT, DICP, IDT, and UNICORN) across almost all environments in both learning efficiency and final asymptotic return.
- Cheetah-Vel (Mixed Dataset): T2MIR-DPT achieved a top score of -43.2, significantly outperforming vanilla DPT (-56.1) and AD (-119.2).
- Meta-World Reach: T2MIR-AD reached a return of 823.9, outperforming vanilla AD (790.4) and IDT (808.5).
- Robustness to Low-Quality Data: When trained on suboptimal Medium datasets, standard baselines suffered severe performance drops. T2MIR maintained stable, high-tier performance, proving its viability for real-world scenarios where expert data is scarce.
Limitations and Future Work
While T2MIR demonstrates clear architectural benefits, the authors note a few limitations:
- Lightweight Datasets: Due to compute constraints, the model was validated on relatively small datasets. Testing T2MIR on massive datasets like XLand-MiniGrid is an essential next step to unlock its true scaling properties.
- Massive Task Scaling: The efficiency of the contrastive loss router when dealing with a massive or infinite number of tasks remains an open question.
- VLA Integration: A promising future direction is deploying T2MIR within Vision-Language-Action (VLA) models, which inherently deal with high multi-modality and diverse task distributions.
Summary updated