TL;DR
TrajMamba is a novel vehicle trajectory pre-training model that leverages the linear-time efficiency of Mamba2 architectures to capture both fine-grained movement patterns and high-level travel purposes. By utilizing contrastive learning with text models during pre-training and a learnable knowledge-distillation compression scheme, it strips away computational redundancy and language model overhead at inference time. The result is a highly accurate trajectory embedding model that executes up to 50 times faster than recent state-of-the-art baselines.
What Problem Does This Paper Address?
Vehicle GPS trajectories are more than just a sequence of coordinates; they contain rich semantic information about how a vehicle moves (speed, acceleration, turns) and why it is traveling (commuting, shopping, leisure). Unlocking these semantics is crucial for intelligent transportation systems (ITS) tasks like destination prediction and arrival time estimation.
However, existing trajectory learning methods face two major bottlenecks:
- Heavy Semantic Overhead: To understand a trip's purpose, models must look at the textual descriptions of nearby Points-of-Interest (POIs) and road functions. Integrating Large Language Models (LLMs) directly into trajectory encoders introduces a massive computational burden.
- Data Redundancy: High-frequency GPS sampling creates highly redundant data points (e.g., idling at a red light or driving straight at a constant speed). Traditional geometric compression algorithms (like Douglas-Peucker) are rule-based, slow, and decoupled from semantic learning.
Methods
TrajMamba addresses these challenges through a three-step pipeline: a dual-perspective encoder, travel purpose-aware pre-training, and a learnable trajectory compression scheme via knowledge distillation.
1. Traj-Mamba Encoder
Instead of relying on computationally heavy Transformers ($O(n^2)$ complexity), the authors design a Traj-Mamba Encoder based on the Mamba2 architecture, achieving linear time complexity ($O(n)$). Each block features two specialized State Space Models (SSMs):
- GPS-SSM: Processes coordinates and temporal deltas, modulated by high-order movement features (speed, acceleration, angle).
- Road-SSM: Captures the geographical space and road network transitions.
A gating mechanism fuses these two perspectives to create a unified trajectory representation.
2. Travel Purpose-aware Pre-training
To capture why a vehicle is moving without dragging down inference speeds, TrajMamba uses a text encoder (e.g., OpenAI's text-embedding-3-large) during pre-training to encode POI and road network descriptions. It then uses contrastive learning (InfoNCE loss) to pull the trajectory embeddings closer to their corresponding textual "views." Crucially, the text encoder is discarded after pre-training, leaving a lightweight trajectory encoder that inherently understands travel context.
3. Knowledge Distillation Pre-training
To handle redundancy, the authors introduce a learnable Mask Generator that uses a sparse stochastic gate to drop non-critical trajectory points. To ensure that compressing the trajectory doesn't destroy its semantic meaning, they employ knowledge distillation: a student network processes the compressed trajectory and is trained to match the full-trajectory embedding generated by the fixed teacher network using a Maximum Entropy Coding (MEC) loss.
Datasets
The model was evaluated on two massive, real-world taxi trajectory datasets released by Didi Chuxing:
- Chengdu: 140,000 trajectories containing over 18 million points.
- Xian: 210,000 trajectories containing over 18 million points.
Road network topologies were extracted from OpenStreetMap, and POI data was retrieved via the AMap API. Trajectories were filtered to lengths between 5 and 120 points.
Key Insights and Ideas
- Decoupling Text from Inference: The most elegant trick in TrajMamba is using contrastive alignment to inject LLM-level semantic understanding into a trajectory model without requiring the LLM during deployment.
- Learnable, Semantic Compression: Instead of compressing trajectories based purely on geometry, TrajMamba's mask generator learns to keep points that matter semantically. For instance, points near the origin and destination are preserved because they carry strong indicators of travel purpose.
- Linear Scaling for Spatiotemporal Data: By adapting Mamba2's selective scan mechanism to handle parallel GPS and road network inputs, the model maintains a highly efficient linear complexity relative to trajectory length, making it ideal for real-time deployment.
Key Results
The authors evaluated TrajMamba across three downstream tasks: Destination Prediction (DP), Arrival Time Estimation (ATE), and Similar Trajectory Search (STS).
Accuracy Gains
TrajMamba consistently outperformed nine state-of-the-art baselines (including Transformer-based models like START and multi-modal models like JGRM). For instance, in Destination Prediction on the Chengdu dataset, TrajMamba slashed the GPS coordinate prediction error (RMSE) down to 129.47 meters, compared to JGRM's 215.99 meters.
Efficiency Boosts
The true strength of TrajMamba lies in its speed. Thanks to its Mamba-based architecture and compressed embeddings, its inference/embedding time is drastically lower than Transformer-based counterparts. On the Chengdu dataset, TrajMamba achieved an embedding time of 1.721 seconds, making it over 54x faster than the closest high-performing baseline, JGRM (94.048 seconds).
Limitations and Future Work
Despite its strong performance, TrajMamba's primary limitation is its cross-city transferability. Because road networks and POI distributions vary drastically between different cities, a model trained on one city struggles with zero-shot migration to another. The authors note that future work will focus on developing universal, transferable road and POI tokenizations to allow models to generalize seamlessly across different urban geographies.
Summary updated