- The paper proposes HTP, a hierarchical framework that generates variable-length trajectories by combining RQ-VAE quantization with LLM semantic conditioning.
- It introduces a relative reconstruction loss and expanded token vocabulary to accurately capture both macro-level travel patterns and micro-level GPS details.
- HTP outperforms state-of-the-art methods with significant metric improvements, achieving up to 80.51% enhancement in urban trajectory realism.
Hierarchical Trajectory Generation via LLMs: A Technical Summary
Motivation and Context
Urban mobility analysis critically depends on large-scale trajectory datasets derived from GPS-enabled devices. However, privacy constraints and collection costs restrict the availability of realistic trajectory datasets with diverse travel behaviors. Existing trajectory generation approaches, leveraging VAE, GAN, or diffusion models, predominantly generate micro-level GPS points directly and typically support only fixed-length outputs under limited conditional settings. These approaches lack explicit modeling of macro-level travel patterns, causing deficiencies in segment-level spatial irregularity and hindering flexible, realistic synthesis of diverse, variable-length trajectories.
HTP: Hierarchical Travel Pattern Generation Framework
The paper introduces the HTP framework, which fundamentally shifts trajectory synthesis from direct GPS-point generation to a hierarchical process comprising macro-level travel pattern generation followed by micro-level GPS reconstruction. The architecture consists of two decoupled stages:
- Trajectory Quantization with Residual Quantization VAE (RQ-VAE): GPS trajectories are compressed into compact travel pattern tokens via a multi-resolution quantization scheme, capturing spatial segment-level irregularities.
- LLM-driven Pattern Generation: LLMs are fine-tunedโincorporating the specialized vocabulary of travel pattern tokensโto generate pattern sequences conditioned on natural language descriptions of trip constraints.
This hierarchical paradigm enables flexible, controlled trajectory synthesis under diverse conditions, supports variable-length outputs, and substantially reduces token generation cost in the LLM.
Figure 1: Pipeline comparison highlighting the hierarchical travel pattern generation in HTP versus direct GPS generation in prior methods.
Figure 2: Architecture overview of HTP, illustrating the joint training of RQ-VAE and LLM for travel pattern synthesis.
Trajectory-specific RQ-VAE: Representation and Quantization
The RQ-VAE is designed to learn shared macro-level travel patterns from high-precision GPS trajectories. The encoder sequentially applies CNN and Transformer layers, compressing the input into segment embeddings by progressive downsampling. Residual quantization is performed across multiple layers, with sequential codebooks expanding token expressiveness to โl=1LโClโ distinct patterns.
Odd-even sequence length fluctuations resulting from non-power-of-two trajectory lengths are explicitly tracked and encoded as length tokens, ensuring bijective reconstruction capability in the decoder. Cross-attentions with contextual road segment embeddings (learned via Node2vec) and linestring geometries introduce explicit spatial constraints, allowing accurate reconstruction in local road-space and mitigating free-space drift.
A key technical advance is the introduction of a relative reconstruction lossโconducting optimization over constrained road segments rather than unconstrained GPS space. This stabilizes training and aligns micro-level trajectories onto road networks while capturing density variations.
Figure 3: Process for deriving training labels for the relative reconstruction loss, leveraging aligned road segment information.
Figure 4: Encoder and decoder design of trajectory-specific RQ-VAE, showing hierarchical feature extraction and compression.
LLM Integration: Semantic Conditioning and Token Efficiency
A fundamental limitation of conventional approaches is rigid condition injection (e.g., only start/end points). HTP generalizes conditioning by expressing constraints (road IDs, time, distance, etc.) as natural language, leveraging the world knowledge and contextual inference capabilities of LLMs. The vocabulary of the LLM is expanded to include travel pattern tokens, road segment tokens, and length tokens, enabling coherent semantic generation and variable-length outputs.
Supervised fine-tuning aligns the LLM to generate travel pattern sequences and associated length tokens under any textual condition. The LLM-generated token sequence is mapped back to quantized embeddings and decoded into GPS via RQ-VAE, merging macro-level semantic control with micro-level spatial realism.
Figure 5: Question-answer format for LLM conditioning on the Chengdu dataset.
Figure 6: Transformation of odd-even sequence length variation into discrete length tokens for robust variable-length decoding.
Experimental Analysis
HTP is evaluated on two populous urban trajectory datasets (Chengdu and Porto). Six SOTA baselines (TrajGAN, TrajVAE, DiffWave, DiffTraj, ControlTraj, Cardiff) are compared across point-level, grid-level, and road-level metrics. HTP demonstrates robust improvements:
- Average quality improvement: 29.78% over the strongest baseline, with up to 80.51% improvement in specific metrics.
- Macro and micro-level realism: HTP achieves superior alignment of trajectory distributions with observed urban patterns at both micro-level (GPS) and macro-level (road/grid).
- Variable-length generation: The produced distribution of trajectory lengths closely matches real data, surpassing diffusion-based models limited to fixed-length outputs.
Figure 7: Visual comparison of generated and real trajectories on Chengdu.
Figure 8: Visual comparison of generated and real trajectories on Porto.
Figure 9: Density distributions of trajectory lengths for real and generated datasets, validating HTP's variable-length output.
Ablation and Hyperparameter Studies
Ablations indicate that each componentโRQ-VAE, relative loss, vocabulary expansion, LLMโsignificantly contributes to generation quality. Removing quantization or loss results in degraded spatial alignment and pattern fidelity, and replacing the LLM with vanilla transformers erodes semantic control.
RQ-VAE codebook size and quantization layer depth are tuned for optimal usage and reconstruction loss. Deeper quantization layers accelerate code utilization and reduce loss, but diminishing returns beyond four layers suggest a balance between complexity and expressiveness.
Figure 10: Codebook layer token utilization rates during RQ-VAE training on Chengdu.
Figure 11: Reconstruction loss versus codebook size and quantization layer number.
Efficiency and Case Studies
HTP achieves efficient generation, compressing required LLM tokens to orders-of-magnitude fewer than direct GPS-point synthesis. Generation speeds are only marginally slower than diffusion baselines while maintaining quality.
Case studies reveal the expressivity of the learned codebooks and the controllability of spatial point density via textual conditionsโallowing route differentiation by time and semantic constraint.
Figure 12: Comparison of generation speed per trajectory between HTP and diffusion-based baselines.
Figure 13: Case study visualization demonstrating codebook pattern expressivity and time-conditioned generation.
Conclusion
HTP establishes a hierarchical paradigm for trajectory generation, combining multi-resolution quantization and semantically conditioned LLM synthesis to produce realistic, variable-length, and diverse urban trajectories. This approach integrates macro-level travel semantics and micro-level spatial precision, substantially advancing trajectory synthetic realism and controllability. The technical insights in hierarchical representation, semantic conditioning, and codebook compression are broadly applicable to the synthesis of other spatial-temporal data modalities and open avenues for further integration between domain-specific tokenization strategies and foundation models in generative modeling.