SIMformer: Single-Layer Vanilla Transformer Can Learn Free-Space Trajectory Similarity

Chuang Yang, Renhe Jiang, Xiaohang Xu, Chuan Xiao, Kaoru Sezaki

Introduction

Calculating the similarity between "free-space" trajectories—such as GPS traces from vehicles or vessels—is a cornerstone of urban planning and navigation systems. While traditional mathematical measures like Dynamic Time Warping (DTW), Hausdorff, and Fréchet distances provide high accuracy, they are computationally intensive, often requiring $O(n^2)$ time. To address this, recent research has shifted toward learning-based methods that encode trajectories into high-dimensional vectors for faster retrieval. However, these methods frequently struggle with the "curse of dimensionality," where Euclidean distance becomes ineffective in high-dimensional spaces, and they often rely on overly complex architectures that hinder scalability.

The SIMformer Architecture

The authors introduce SIMformer, a minimalist model designed to overcome these challenges. Departing from the trend of deep, multi-layer LSTMs or complex grid-based features, SIMformer utilizes a single-layer vanilla Transformer encoder. This architecture leverages self-attention to capture global dependencies in parallel, significantly improving training and inference speeds.

The SIMformer architecture uses a single-layer Transformer and pair-wise MSE loss to learn trajectory representations.

A key departure from existing literature is the training objective. Instead of the standard Triplet Loss, which requires complex sample mining (anchors, positives, and negatives), SIMformer employs a straightforward Pair-wise Mean Squared Error (MSE) loss. This approach directly aligns the learned representation similarity with the ground-truth mathematical distance.

Tailored Similarity Functions

The core innovation of SIMformer lies in its use of "tailored" similarity functions. The authors argue that forcing a model to use Euclidean distance in high-dimensional space restricts its "feasible solution space," making it harder to learn complex metrics. By matching the similarity function to the mathematical nature of the target metric, the model can more easily converge on an accurate representation.

Geometric representations of (a) Euclidean, (b) Chebyshev, and (c) Cosine similarity spaces used to tailor the model to specific trajectory metrics.

Specifically:

  • Cosine Similarity is paired with DTW, as both emphasize accumulated global variations.
  • Chebyshev Distance (focusing on the maximum difference in any single dimension) is paired with Hausdorff and Fréchet distances, which are defined by "worst-case" local differences.

Key Results and Scalability

SIMformer was evaluated across diverse real-world datasets, including taxi traces (Porto, T-Drive), human movement (Geolife), and maritime vessel trajectories (AIS). The results demonstrate significant improvements over state-of-the-art baselines:

  • Accuracy: On the Porto dataset for DTW, SIMformer achieved a 41.68% improvement in the Top-1 hit ratio.
  • Ranking Quality: The model reduced ranking inversions by an average of 20.08%, indicating a more reliable ordering of search results.
  • Efficiency: SIMformer is 30% faster during inference and requires 10% less GPU memory than leading complex models.
  • Scalability: In large-scale tests involving 1 million trajectories, SIMformer maintained a hit rate above 50%, whereas the performance of competing models collapsed under the increased data volume and noise.

Conclusion

SIMformer demonstrates that minimalism in model design—when combined with mathematically aligned similarity functions—can outperform complex, deep-learning architectures for trajectory analysis. While the current model struggles with heterogeneous "edit distance" measures (like EDR or ERP), its success in free-space trajectory similarity provides a robust and scalable foundation for future research in spatial-temporal data mining.

Summary updated

BibTeX
@article{yang2024simformer,
  author = {Chuang Yang and Renhe Jiang and Xiaohang Xu and Chuan Xiao and Kaoru Sezaki},
  title = {{SIMformer: Single-Layer Vanilla Transformer Can Learn Free-Space Trajectory Similarity}},
  journal = {Proc. VLDB Endow.},
  year = {2024},
  url = {https://openreview.net/forum?id=LJvSDxfxLx},
}
Figure