Papers
Topics
Authors
Recent
Search
2000 character limit reached

From GPS Points to Travel Patterns: Flexible and Semantic Trajectory Generation with LLMs

Published 28 May 2026 in cs.AI | (2605.30014v1)

Abstract: Urban trajectories play a crucial role in modeling urban dynamics and supporting various smart city applications. However, privacy concerns restrict access to large-scale and high-quality trajectory datasets. Trajectory generation provides a promising alternative by synthesizing realistic data to mitigate privacy risks. However, existing methods fail to explicitly capture travel patterns and can only generate fixed-length trajectories under a single condition. To address these limitations, we propose \textbf{HTP}, which \textbf{H}ierarchically generates \textbf{T}ravel patterns first and then generates GPS \textbf{P}oints by using LLMs, rather than directly generating GPS points. We first design a trajectory-specific residual quantization variational autoencoder (RQ-VAE) that quantizes micro-level GPS trajectories into compact, macro-level travel pattern tokens in a coarse-to-fine manner. These tokens capture rich segment spatial irregularities, such as point density variations caused by traffic conditions. Then, we extend the LLM vocabulary with travel pattern tokens to align trajectory representations with the LLM input, and apply supervised fine-tuning (SFT) to align the LLM with the trajectory generation task, enabling generation of travel pattern sequences under various conditions. Extensive experiments on two real-world datasets show that HTP outperforms the strongest baseline by an average of 29.78\% in terms of generation quality. Our code is available at https://github.com/slzhou-xy/HTP.

Summary

  • 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:

  1. 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.
  2. 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

Figure 1: Pipeline comparison highlighting the hierarchical travel pattern generation in HTP versus direct GPS generation in prior methods.

Figure 2

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=1LCl\prod_{l=1}^{L}C_l 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

Figure 3: Process for deriving training labels for the relative reconstruction loss, leveraging aligned road segment information.

Figure 4

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

Figure 5: Question-answer format for LLM conditioning on the Chengdu dataset.

Figure 6

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

    Figure 7: Visual comparison of generated and real trajectories on Chengdu.

    Figure 8

    Figure 8: Visual comparison of generated and real trajectories on Porto.

    Figure 9

    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

Figure 10: Codebook layer token utilization rates during RQ-VAE training on Chengdu.

Figure 11

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

Figure 12: Comparison of generation speed per trajectory between HTP and diffusion-based baselines.

Figure 13

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.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.

Tweets

Sign up for free to view the 1 tweet with 1 like about this paper.