XTraj: A Coarse-to-Fine Autoregressive Framework for Transferable Trajectory Generation

Chao Wang, Zhiquan Lai, Xinwei Fang, Yuanshao Zhu, Xun Zhou, James Jianqiao YuNeurIPS 2026

TL;DR

Generating realistic GPS vehicle trajectories for city planning is notoriously brittle: models usually memorize a single city's layout, force every trip into a fixed length, and accidentally drive synthetic cars straight through buildings. XTraj solves all three problems by ditching raw 2D coordinate generation in favor of a "coarse-to-fine" approach: it first picks a logical sequence of road segments, then predicts how far a car inches forward along that exact path at each step. Because it learns universal road features rather than local GPS grids, a model trained in one city can be dropped into a brand-new city and generate physically valid traffic right out of the box.

What Problem Does This Paper Address?

Real-world human mobility data—like ride-share GPS logs—is gold for traffic planners and urban engineers, yet nearly impossible to share due to strict privacy and proprietary walls. Synthetic trajectory generation offers a great workaround, especially with recent diffusion models. However, when you try to deploy current generators in practice, you hit three frustrating walls:

  1. Geographic Overfitting: Models learn patterns tied to a specific city’s coordinate grid or unique road IDs. Train a model in Xi'an, and it is useless in Chengdu.
  2. Length-Rigid Generation: Diffusion models usually require resampling every trip—whether a 5-minute errand or a 1-hour commute—into a fixed number of GPS points (say, 200), distorting natural travel speeds and sampling densities.
  3. Off-Road Drift: Generating unconstrained $(x, y)$ coordinates in continuous space inevitably places cars in rivers or living rooms, requiring error-prone post-hoc "map matching" to snap points back onto valid streets.

The authors ask: Can we build a single trajectory generator that guarantees 100% on-road accuracy, adapts naturally to any trip length, and transfers to unseen cities with zero retraining?

Methods

Instead of trying to hallucinate raw latitude and longitude points all at once, XTraj breaks the problem into three intuitive, sequential stages:

Figure 1: the overall workflow of XTraj. A pretrained GAT encodes road segments, the Road- Segment-Level Autoregressive Generator produces a road-segment route, and the Road-Aligned GPS Generator decodes that route into a GPS trajectory.
  • 1. Transferable Road-Segment Encoder: To avoid memorizing city-specific coordinates, XTraj describes every road segment using universally available attributes: road geometry, nearby Points of Interest (POIs), and historical traffic heat. Stacked Graph Attention Networks (GATs) blend these features with local street topology. Crucially, the authors pretrain this encoder using a BERT-style masked reconstruction task on real routes so the embeddings capture how humans actually string roads together.
  • 2. Road-Segment Autoregressive (AR) Generator: Given an origin, destination, and departure time, a causal Transformer predicts the trip one road segment at a time until it hits the destination—naturally handling variable route lengths. To keep the model honest, XTraj applies two masks during decoding: a topology mask (only allowing legally connected turns) and a distance-monotone constraint (forcing each chosen road to get at least as close to the destination as the last, preventing infinite loops or aimless wandering).
  • 3. Road-Aligned GPS Generator: This is the cleverest twist. Rather than predicting 2D coordinates, an encoder-decoder Transformer operates in 1D route-progress space. At each timestamp, it predicts a non-negative forward increment ($\Delta s$) via a Softplus activation, paced by how much trip duration remains. Recovering exact GPS coordinates is then just deterministic math—interpolating along the known geometry of the chosen road segments. Off-road drift becomes mathematically impossible.
Detailed three-module architecture of XTraj.

Datasets

The authors evaluate XTraj using two real-world vehicle trajectory datasets from DiDi Chuxing, covering the Chinese cities of Xi'an and Chengdu (which feature notably different street layouts and driving patterns). Raw GPS traces are map-matched onto directed road graphs and POI contexts pulled from OpenStreetMap. No new benchmark datasets are introduced.

Key Insights and Ideas

  • 1D Progress Beats 2D Coordinates: Reframing GPS generation from unconstrained 2D space to monotonic 1D progress along a path does double duty: it guarantees zero off-road drift by construction and decouples the generator from local coordinate bounds so it works anywhere.
  • Shortest Paths Aren't Human Paths: In ablations, swapping out the learned Road-Segment AR Generator for a deterministic shortest-path router still reached destinations 100% of the time, yet significantly degraded spatial density fidelity (e.g., worsening Jensen-Shannon divergence from 0.0412 to 0.0966 in Chengdu). Human drivers have nuanced route preferences that simple shortest-path math misses.
  • Guardrails Save Zero-Shot Transfer: Inside a familiar training city, removing the destination-distance hard constraint barely dents route completion (dropping from 100% to ~98.9% in Xi'an). When transferred zero-shot to an unfamiliar city, however, completion without that constraint plummets to 15.6%. Learned local intuition gets shaky in new towns; explicit topological guardrails keep the model on track.

Key Results

  • Superior Spatial Fidelity: Measured by Jensen–Shannon divergence (JSD, lower is better) on a $256 \times 256$ spatial density grid, XTraj hits 0.0592 in Xi'an and 0.0412 in Chengdu—handily beating strong diffusion baselines like ControlTraj (0.1545 / 0.1172, even though ControlTraj is handed ground-truth routes!) and CarDiff (0.1801 / 0.1664). This lead holds across eight spatial grid resolutions, down to 1-meter street-level granularity.
  • Zero Off-Road Drift: While diffusion baselines place ~95–98% of their points off-road—averaging 13.6m to 30.0m away from valid streets—XTraj achieves a 0.00m average shift and 0.0000 post-hoc map-matching rate by construction. (Another road-network baseline, Diff-RNTraj, also achieves 0.00m shift, but suffers from over $60\times$ worse trip-length distribution errors due to fixed-length diffusion).
  • Training-Free Cross-City Transfer: When trained on Chengdu and dropped directly into Xi'an with zero fine-tuning, XTraj-Transfer achieves a Density JSD of 0.0747—outperforming baselines that were actually trained on Xi'an. Meanwhile, coordinate-bound diffusion models completely collapse in unseen cities (Density JSD degrading past 0.53).

Limitations and Future Work

Not discussed in the paper.

Summary updated

Abstract

Generating realistic human trajectories is essential for mobility simulation but remains challenging when they must generalize across cities and respect road network constraints. In practice, existing methods often suffer from three key limitations: geographic overfitting, length-rigid generation, and off-road drift when generating GPS coordinates directly. To address these issues, we propose $\textbf{XTraj}$, a transferable coarse-to-fine autoregressive framework for road-consistent trajectory generation. Specifically, XTraj first learns transferable road-segment representations by integrating road geometry, POI context, historical traffic intensity, and graph topology. Based on these representations, it then autoregressively generates variable-length road-segment routes under road-connectivity constraints. Finally, instead of directly generating coordinates, XTraj refines each generated route in a route-progress space by predicting monotonic progress increments along valid road geometry, from which GPS points are recovered by interpolation. This route-aligned design naturally supports variable-length GPS generation and guarantees road-geometry consistency by construction. Experiments on two real-world trajectory datasets show that XTraj improves spatial fidelity over competitive baselines, transfers effectively to unseen cities in a zero-shot setting, and ensures road-geometry consistency by construction without any post-hoc map matching.
BibTeX
@inproceedings{wang2026xtraj,
  author = {Chao Wang and ZHIQUAN LAI and Xinwei Fang and Yuanshao Zhu and Xun Zhou and James Jianqiao Yu},
  title = {{XTraj: A Coarse-to-Fine Autoregressive Framework for Transferable Trajectory Generation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=KXGb143xQb},
}
Figure