Under the hood of transformer networks for trajectory forecasting

Luca Franco, Leonardo Placidi, Francesco Giuliari, Irtiza Hasan, Marco Cristani, Fabio Galasso · DOI

TL;DR

This paper provides the first systematic "ablation study" of Transformer networks for human trajectory forecasting, stripping away complex social and environmental modules to evaluate the core architecture. The authors demonstrate that Transformers and BERT significantly outperform LSTMs in modeling individual motion, particularly when paired with a quantized classification approach rather than standard regression.

What Problem Does This Paper Address?

Predicting where a person will walk next is a cornerstone of autonomous driving and human-robot interaction. For years, the field has moved toward increasingly complex models that incorporate "social pooling" (how people avoid each other) and "scene context" (not walking through walls).

However, this complexity created a blind spot: we didn't actually know if the underlying sequence models (like Transformers) were better at modeling the basic physics and intent of a single person’s movement, or if they were just better at "social" math. This paper goes "under the hood" to compare LSTMs, Transformers (TF), and Bidirectional Transformers (BERT) on individual motion patterns alone, without any "bells and whistles."

Methods

The researchers conducted an exhaustive comparison across three dimensions:

  1. Architectures: They compared the classic LSTM (Recurrent) against the Transformer (Auto-regressive) and BERT (Bidirectional). They also introduced BERT-OS (One-Shot), which predicts the entire future path simultaneously rather than step-by-step.
  2. Problem Formulations:
    • Regression: Directly predicting $(x, y)$ coordinates using L2 loss.
  3. Unimodal Gaussian: Predicting the mean and variance of the next position.
  4. Quantized Multinomial: Treating the next move as a classification problem. They clustered thousands of possible movements into 1,000 "bins" (K-Means) and tasked the model with picking the right bin.
  5. Input Representations: Comparing whether it's better to feed the model absolute Positions or relative Speeds.

Datasets

The study utilizes the ETH+UCY benchmark, the gold standard in the field, which consists of five sub-datasets (ETH, Hotel, Univ, Zara1, and Zara2) containing real-world pedestrian trajectories. To analyze multi-modality, they also created a modified version of these datasets where trajectories are aligned and clustered to highlight the different "forking paths" a person might take from the same starting point.

Key Insights and Ideas

  • The Memory Advantage: Why do Transformers beat LSTMs? The authors attribute this to memory. LSTMs compress the entire past into a single hidden state (a bottleneck). Transformers use attention to maintain "unlimited" access to every observed frame, preventing the "forgetting" that plagues LSTMs over long horizons.
  • Classification > Regression: Surprisingly, treating trajectory prediction as a 1,000-way classification task (Quantized Multinomial) yielded the best results for Transformers. This allows the model to express multi-modal futures (e.g., "the person might turn left OR right") which a simple regression model struggles to capture.
  • BERT as a "Denoiser": When using BERT-OS with an "oracle" endpoint (telling the model exactly where the person ends up), the model doesn't just draw a straight line. It "denoises" the path, generating a physically plausible trajectory that respects human motion dynamics.
  • Parallelization: Unlike LSTMs, which must be processed sequentially, Transformers allow for parallel training across time steps, making them more scalable for large-scale trajectory data.

Key Results

  • Superior Accuracy: Transformers and BERT consistently outperformed LSTMs by a wide margin—roughly 25% less error in Mean Average Displacement (MAD) and Final Average Displacement (FAD).
  • The Top Performer: The Transformer using the Quantized Multinomial formulation was the overall winner, achieving an average MAD of 0.53m and FAD of 1.13m on the benchmark.
  • Long-Term Stability: As the prediction horizon increased from 12 to 32 frames, the Transformer's performance degraded much more gracefully than the LSTM's, proving its robustness for long-term forecasting.
  • Intent-Driven Success: Providing BERT with a target goal (endpoint) reduced the final error to just 0.30m, suggesting that future models should focus heavily on "goal estimation" as a first step.

Limitations and Future Work

The primary limitation is the one the authors set for themselves: the exclusion of social and scene context. While this was necessary to study the "core" architecture, real-world pedestrians are rarely alone.

The authors suggest that the next logical step is to integrate these high-performing "temporal-only" Transformers into frameworks that handle social interactions. Additionally, while the Quantized Multinomial approach performed best, it is computationally expensive and requires careful tuning of the number of clusters ($K$). Finding a more efficient way to represent these discrete movement "atoms" is a promising direction for future research.

Summary updated

BibTeX
@article{franco2023under,
  author = {Luca Franco and Leonardo Placidi and Francesco Giuliari and Irtiza Hasan and Marco Cristani and Fabio Galasso},
  title = {{Under the hood of transformer networks for trajectory forecasting}},
  journal = {Pattern Recognition},
  year = {2023},
  doi = {10.1016/j.patcog.2023.109372},
}
Figure