NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Contrastive Learning-Based Agent Modeling for Deep Reinforcement Learning

Wenhao Ma, Yu-Cheng Chang, Jie Yang, Yu-Kai Wang, Chin-Teng LinIEEE Trans. Emerg. Top. Comput. Intell 2023

Abstract

Multi-agent systems often require agents to collaborate with or compete against other agents with diverse goals, behaviors, or strategies. Agent modeling is essential when designing adaptive policies for intelligent machine agents in multiagent systems, as this is the means by which the ego agent understands other agents' behavior and extracts their meaningful policy representations. These representations can be used to enhance the ego agent's adaptive policy which is trained by reinforcement learning. However, existing agent modeling approaches typically assume the availability of local observations from other agents (modeled agents) during training or a long observation trajectory for policy adaption. To remove these constrictive assumptions and improve agent modeling performance, we devised a Contrastive Learning-based Agent Modeling (CLAM) method that relies only on the local observations from the ego agent during training and execution. With these observations, CLAM is capable of generating consistent high-quality policy representations in real-time right from the beginning of each episode. We evaluated the efficacy of our approach in both cooperative and competitive multi-agent environments. Our experiments demonstrate that our approach achieves state-of-the-art on both cooperative and competitive tasks, highlighting the potential of contrastive learning-based agent modeling for enhancing reinforcement learning.

Introduction

In the complex dance of multi-agent systems—whether it's robots collaborating on a factory floor or players competing in a video game—success depends on "reading the room." To cooperate or compete effectively, an agent needs to understand the strategies and intentions of its peers. This paper introduces CLAM (Contrastive Learning-based Agent Modeling), a novel framework that allows agents to build sophisticated mental models of their counterparts using nothing but their own local observations.

The Challenge of Agent Modeling

In Multi-Agent Reinforcement Learning (MARL), agent modeling is the process of inferring the policies or goals of other agents. Most existing approaches suffer from two major "constrictive assumptions":

  1. Privileged Information: They often assume that during training, the learning agent (the "ego agent") has access to the internal observations of the agents it is modeling. In the real world—especially when interacting with humans—this is rarely possible.
  2. Slow Adaptation: Many models require a long history of observations before they can accurately identify a peer's strategy, making them ineffective in fast-paced, real-time environments.

CLAM addresses these gaps by asking: Can an agent learn to represent its peers' strategies effectively using only what it sees from its own perspective, and can it do so from the very first steps of an interaction?

The CLAM Framework

The CLAM model consists of two primary components integrated into a standard Reinforcement Learning pipeline:

  • Transformer Encoder: Since agent interactions are sequential, CLAM uses a Transformer to capture long-range temporal patterns within the ego agent's observation trajectories.
  • Attention Pooling: Instead of simply averaging features over time, CLAM uses a trainable "policy token" and an attention mechanism to weigh specific moments in a trajectory more heavily. This allows the model to focus on the most "telling" actions that reveal an opponent's strategy.
The CLAM training architecture uses asymmetric contrastive learning to extract policy representations from local observation trajectories.

The core innovation is the Asymmetric Contrastive Learning strategy. The model takes two crops of the same trajectory (a positive pair). One crop undergoes "strong augmentation" (randomly masking steps), while the other remains "weakly augmented." By forcing the model to match these two versions, CLAM learns to extract the most representative features even from sparse or noisy data.

Experimental Evaluation

The researchers evaluated CLAM across three diverse multi-agent benchmarks to test its versatility in both cooperative and competitive settings:

  • Level-based Foraging: A cooperative grid world where agents must coordinate their "levels" to pick up apples.
  • Predator-Prey: A competitive environment where three predators (fixed policies) try to catch one prey (the learning ego agent).
  • StarCraft Multi-Agent Challenge (SMAC): A complex, mixed cooperative-competitive environment. The authors used the 3m and 2s3z maps to test coordination against adversarial teammates.
Evaluation environments: (left) Level-based foraging, (center) Predator-prey, and (right) StarCraft Multi-Agent Challenge (SMAC).

Key Results and Insights

  • Performance Boost: CLAM improved reinforcement learning performance by at least 28% compared to state-of-the-art baselines like LIAM and PR.
  • Superior Coordination: In StarCraft (SMAC), the win rate for CLAM was approximately three times higher than a baseline PPO agent that lacked agent modeling.
  • Rapid Identification: CLAM's predictive accuracy for other agents' actions jumped from a random 20% to over 50% within just 10 steps, stabilizing above 70% by step 30. This demonstrates true real-time adaptation.
  • Local Perspective is Sufficient: The paper proves that an agent doesn't need to "cheat" by looking at a peer's private data. How a peer reacts to the ego agent's presence is a strong enough signal to decode their policy.

Conclusion and Future Work

CLAM demonstrates that asymmetric contrastive learning is a powerful tool for real-time agent modeling using only local observations. While highly effective, the model can still struggle to distinguish between policies that are inherently very similar (e.g., two different predator strategies that both involve aggressive pursuit).

Looking ahead, the team aims to extend CLAM to human-machine collaboration. This would involve integrating vision models to process raw visual inputs, allowing a robot to extract human behavioral features and environmental context simultaneously to become a more intuitive partner.

Summary updated

BibTeX
@article{ma2023contrastive,
  author = {Wenhao Ma and Yu-Cheng Chang and Jie Yang and Yu-Kai Wang and Chin-Teng Lin},
  title = {{Contrastive Learning-Based Agent Modeling for Deep Reinforcement Learning}},
  journal = {IEEE Trans. Emerg. Top. Comput. Intell},
  year = {2023},
}
Figure