AgentFormer: Agent-Aware Transformers for Socio-Temporal Multi-Agent Forecasting

Ye Yuan, Xinshuo Weng, Yanglan Ou, Kris Kitani · DOI

Abstract

Multi-agent trajectory forecasting is a critical component for autonomous systems, requiring the simultaneous modeling of temporal dynamics and social interactions. Traditional approaches often decouple these dimensions, leading to information bottlenecks. We present AgentFormer, a novel Transformer-based framework that enables joint socio-temporal modeling by flattening trajectories into a single sequence. By introducing an agent-aware attention mechanism, AgentFormer allows for direct influence between any agent's past state and any other agent's future state. Our model achieves state-of-the-art performance on both pedestrian and vehicle trajectory benchmarks.

Introduction

Predicting the future trajectories of multiple interacting agents—such as pedestrians in a crowded street or vehicles at a busy intersection—is a fundamental challenge for autonomous navigation. To succeed, a model must master two distinct dimensions: the temporal dimension (how an agent's history dictates its future) and the social dimension (how agents react to one another).

Most existing architectures follow a "temporal-then-social" pipeline. They typically use recurrent neural networks (RNNs) to summarize an agent's history into a fixed-length vector, which is then processed by a social interaction module like a Graph Neural Network (GNN) or a pooling layer. However, this sequential processing creates a significant information bottleneck. Fine-grained temporal details, such as a subtle change in heading or speed several seconds prior, may be lost during summarization, even though they might be crucial for another agent's reaction.

Comparison of AgentFormer vs. Standard Models

Methodology

AgentFormer rethinks multi-agent forecasting as a sequence-to-sequence problem where the sequence encompasses all agents across all timesteps.

Joint Socio-Temporal Modeling

The core innovation lies in treating the entire multi-agent scene as a single flattened sequence. In this representation, every "agent-at-a-timestep" is an individual token. This allows a standard Transformer architecture to perform global attention, where any state of any agent can directly attend to any other state, regardless of time or identity. This bypasses the need for intermediate summary vectors and preserves high-resolution information throughout the network.

Agent-Aware Attention

Standard Transformers are permutation-invariant and "agent-blind." While positional encodings can handle time, simply adding an Agent ID tag is insufficient for the model to distinguish between self-history and social influence. AgentFormer introduces a specialized Agent-Aware Attention mechanism. It uses a masking strategy and distinct linear transformations for intra-agent (self) and inter-agent (social) interactions. This ensures the model maintains agent identity and learns to weigh its own past trajectory differently from the movements of surrounding agents.

Stochastic Forecasting with CVAE

Because the future is inherently uncertain, AgentFormer is integrated into a Conditional Variational Autoencoder (CVAE) framework. The model learns a joint latent distribution representing the "intents" of all agents. By modeling these intents jointly, the system captures how the uncertainty of one agent (e.g., a pedestrian deciding whether to cross) propagates through the entire scene, affecting the predicted paths of everyone else.

AgentFormer CVAE Architecture

Key Insights

The researchers found that the relationship between self-attention and social-attention is the primary driver of performance. By utilizing different keys and queries for "self" versus "others," the model effectively learns the nuances of social navigation. Furthermore, the direct connectivity allowed by the Transformer means a vehicle's predicted position ten seconds in the future can be directly influenced by a pedestrian's specific footstep observed seconds earlier, a level of granularity difficult to achieve with recurrent models.

Results

AgentFormer was evaluated on two major benchmarks: ETH/UCY for pedestrian dynamics and nuScenes for complex urban driving.

  • Pedestrians (ETH/UCY): AgentFormer significantly outperformed previous state-of-the-art models like Trajectron++ and STAR. It showed particular strength in reducing Final Displacement Error (FDE), indicating superior long-term forecasting capabilities.
  • Driving (nuScenes): In the vehicle prediction challenge, AgentFormer achieved an Average Displacement Error (ADE) of 1.45m (at $K=10$ samples), surpassing the competitive Trajectron++ benchmark of 1.51m.

Ablation studies confirmed that the Agent-Aware Attention mechanism was the most critical component, with its removal leading to a substantial drop in accuracy compared to other features like semantic maps.

Discussion and Limitations

While AgentFormer offers a powerful new paradigm, it faces challenges related to computational complexity. The quadratic scaling of Transformers with respect to sequence length ($N \times T$) means that as the number of agents or the time horizon increases, memory and compute requirements grow rapidly. This may limit real-time deployment in extremely dense environments without further optimization. Additionally, the current model uses an autoregressive decoder, which generates future steps sequentially and is generally slower than non-autoregressive alternatives. Future work may explore more efficient attention mechanisms or non-autoregressive decoding to improve inference speed for real-time robotics applications.

Summary updated

BibTeX
@inproceedings{yuan2021agentformer,
  author = {Ye Yuan and Xinshuo Weng and Yanglan Ou and Kris Kitani},
  title = {{AgentFormer: Agent-Aware Transformers for Socio-Temporal Multi-Agent Forecasting}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2021},
  doi = {10.1109/iccv48922.2021.00967},
}
Figure