Contrastive Modules with Temporal Attention for Multi-Task Reinforcement Learning

Siming Lan, Rui Zhang, Qi Yi, Jiaming Guo, Shaohui Peng, Yunkai Gao, Fan Wu, Ruizhi Chen, Zidong Du, Xing Hu, Xishan Zhang, Ling Li, Yunji Chen

Abstract

Multi-task reinforcement learning (MTRL) aims to leverage shared knowledge across tasks to improve learning efficiency. However, existing modular architectures often suffer from module redundancy and "negative transfer" due to coarse-grained module selection. We propose Contrastive Modules with Temporal Attention (CMTA), a framework that enforces module distinctiveness through a contrastive loss and utilizes a temporal attention mechanism for dynamic, fine-grained module weighting. Evaluated on the Meta-World benchmark, CMTA significantly outperforms state-of-the-art methods and, for the first time, exceeds the performance of single-task training baselines.

Introduction

The primary goal of MTRL is "positive transfer," where learning related tasks accelerates the acquisition of new skills. Despite this potential, agents often encounter "negative transfer," where conflicting gradients from different tasks degrade performance below that of single-task learning. Current modular MTRL approaches attempt to mitigate this by partitioning the network into specialized "experts." However, these methods face two critical challenges:

  1. Redundancy: Modules often converge to similar functions without explicit diversity constraints, wasting capacity.
  2. Coarse Granularity: Most architectures fix module assignments at the start of an episode, failing to account for the distinct temporal phases within a single task (e.g., reaching vs. pushing).

Methodology: CMTA

CMTA addresses these issues by integrating two core components into a Soft Actor-Critic (SAC) framework.

Contrastive Modules

To ensure modules learn unique, specialized features, CMTA employs a contrastive loss based on the InfoNCE objective. For each module, its output at the next time step serves as a positive pair, while the outputs of other modules at the current time step serve as negative samples. This objective forces each expert to represent distinct aspects of the state space, preventing the network from collapsing into redundant configurations.

Temporal Attention

Recognizing that tasks are non-stationary, CMTA implements a dynamic weighting scheme. An LSTM processes the history of the episode ($s_t, h_{t-1}$) to generate a hidden state $h_t$. This state, concatenated with a task embedding $z_{task}$, informs an attention mechanism that re-weights expert contributions at every time step. This allows the agent to switch between specialized modules as the task progresses through different sub-stages.

The CMTA Architecture: Experts are constrained by contrastive loss and combined via temporal attention

Experimental Setup

We evaluated CMTA on the Meta-World benchmark, focusing on the MT10 and MT50 suites. To rigorously test generalization, we utilized both "Fixed" and "Mixed" settings. The "Mixed" setting randomizes initial object positions across 50 variations, requiring the agent to infer task objectives dynamically rather than relying on memorized trajectories.

Results and Discussion

CMTA demonstrates substantial improvements over baselines such as CARE, Soft Modularization, and MT-SAC.

Performance and Sample Efficiency

In the MT50-Mixed environment, CMTA achieved a success rate of 71.69%, a significant margin over the 45.00% achieved by the next-best method, CARE. Furthermore, training curves indicate that CMTA is more sample-efficient, reaching higher success rates earlier in the training process than competing modular approaches.

Training curves showing CMTA outperforming all baselines across MT10 and MT50

Surpassing the Single-Task Ceiling

A notable achievement of CMTA is its ability to outperform single-task SAC baselines. In MT10-Fixed, CMTA reached a 78.95% success rate, compared to 64.33% for single-task training. This suggests that the forced modularity in CMTA provides a beneficial regularization effect, enabling better generalization than learning tasks in isolation.

Conclusion

CMTA effectively addresses the challenges of module redundancy and coarse-grained task representation in MTRL. By combining contrastive learning with temporal attention, the model achieves state-of-the-art results on complex robotic manipulation benchmarks. Future work will explore the scalability of contrastive modules and the application of dynamic modularity to few-shot meta-learning scenarios.

Summary updated

BibTeX
@inproceedings{lan2023contrastive,
  author = {Siming Lan and Rui Zhang and Qi Yi and Jiaming Guo and Shaohui Peng and Yunkai Gao and Fan Wu and Ruizhi Chen and Zidong Du and Xing Hu and Xishan Zhang and Ling Li and Yunji Chen},
  title = {{Contrastive Modules with Temporal Attention for Multi-Task Reinforcement Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=WIrZh2XxLT},
}
Figure