← All research

Under review · AAAI 2027

StayBERT: Staypoint Detection as the Pretext Task for Trajectory Foundation Models

Riyang Bao*, Mingke Tian*, Andreas Züfle, Liang Zhao

Emory University · * Equal contribution

Problem
A pretext task for trajectory foundation models
Data
Pretrained on SF-LIFE; transferred to Atlanta and GeoLife
Key idea
Detect stays from motion and place, decoded as coherent spans
Status
Under review
StayBERT overview: (A) a motion view (TCN smoothing and a Transformer) and a place view (a Sphere2Vec query attending over nearby POIs, mobility graphs, and region semantics) are fused by a gate; (B) a CRF decoder labels stop and move points, marginal-weighted pooling forms staypoint embeddings, and pretraining combines a balanced CRF loss with reconstruction, boundary, and segment losses; Geo-TTST updates only the CRF head on confident pseudo-labels in a target city.
Figure 1. Overview. (A) Motion–place encoder: the motion view encodes coordinate evolution, elapsed time, and speed; a Sphere2Vec query composes POI, mobility-graph, and regional-semantic context; a dimension-wise gate fuses the two views. (B) Dwell learning: a CRF decodes coherent stop/move spans and marginal-weighted pooling forms staypoint representations; the balanced CRF loss is the primary objective, with reconstruction, boundary, and segment terms; ATR thins observations. Bottom lane: Geo-TTST selects pseudo-labels by geo-conditioned confidence and updates only the CRF head.

1Problem and significance

A GPS trajectory is a sequence of \(N\) timestamped locations. Staypoint detection labels every point as stop or move:

\[\begin{gathered}\mathcal{T}=\{(\ell_i,t_i)\}_{i=1}^{N},\qquad \ell_i=(\mathrm{lat}_i,\mathrm{lon}_i),\\ y_i\in\{\text{stop},\text{move}\}.\end{gathered}\]

Here \(\ell_i\) are coordinates and \(t_i\) timestamps. A maximal contiguous span labeled stop defines a dwell episode \(s\). The target therefore has two parts: point-level movement evidence and the temporal coherence of the resulting span.

  • Staypoints are the unit that mobility analysis consumes. Home/work inference, next-location prediction, anomaly detection, activity recognition, and duration forecasting all operate on staypoint-level histories, their semantic labels, and their dwell times.
  • Detection requires motion and place jointly. Low speed may indicate an activity, congestion, a traffic signal, or positioning noise. Separating these cases requires spatial concentration, temporal persistence, arrival and departure transitions, and whether the surrounding geography supports a stay.
  • Cities differ. Sampling rates, mobility patterns, and available geographic context change across regions, so a representation learned in one city must transfer and must remain usable when some context source is missing.

The goal is to use staypoint detection as a pretext task: learn an encoder on a labeled source city that produces a fused state \(\mathbf{h}_i\) per point, a coherent stop/move decoding, and a staypoint representation \(\mathbf{z}_s\),

\[\mathcal{T}\ \longrightarrow\ (\mathbf{m}_i,\mathbf{g}_i)\ \longrightarrow\ \mathbf{h}_i\ \longrightarrow\ \mathrm{CRF}\ \longrightarrow\ \mathbf{z}_s,\]

such that the frozen \(\mathbf{z}_s\), read by lightweight task-specific heads, supports diverse downstream tasks in the source city and in other cities.

2Research questions

Equation (2) makes three claims that must be tested separately: the pretext must be learnable as coherent spans; the pooled representation must be reusable without per-task backbone training; and it must survive a change of city, with or without unlabeled target data. A fourth question asks which geographic sources the transfer depends on.

Table 1. Research questions, the component that addresses each, and the evidence reported below.
RQQuestionAddressed byEvidence
RQ1Can stop/move spans be detected accurately from fused motion and place evidence under a structured objective?Motion–place encoder, CRF decoding, dwell-structured objective (§3.1–3.5)Table 3
RQ2Does one frozen staypoint representation support semantic, anomaly, duration, and sequential tasks in the source city?Marginal-weighted staypoint pooling (§3.4)Table 4
RQ3Does the representation transfer to other cities and datasets without target labels, and does unlabeled target adaptation add to it?City-agnostic place interface (§3.2); Geo-TTST (§3.6)Tables 5–8
RQ4Which geographic sources (POIs, regional semantics, mobility graph, continuous coordinates) does the representation depend on?Place view components (§3.2)Tables 9–10

3Method

StayBERT has five components: a motion view producing \(\mathbf{m}_i\in\mathbb{R}^{256}\); a place view producing a query-conditioned geographic state \(\mathbf{g}_i\in\mathbb{R}^{128}\); a dimension-wise gate that fuses them into \(\mathbf{h}_i\in\mathbb{R}^{128}\); a linear-chain CRF with marginal-weighted staypoint pooling; and a dwell-structured pretraining objective. Geo-Conditional Test-Time Self-Training (Geo-TTST) is an optional target-city adaptation step that updates only the CRF head. Algorithm 1 gives pretraining and downstream use; Algorithm 2 gives Geo-TTST.

Algorithm 1  StayBERT pretraining and frozen downstream use

Input: labeled source trajectories \(\mathcal{D}=\{(\mathcal{T}^{(k)},\mathbf{y}^{(k)})\}\); GeoContext sources on a spatial grid; weights \(\lambda_{\mathrm{rec}},\lambda_{\mathrm{bnd}},\lambda_{\mathrm{seg}},\beta,w_{\mathrm{move}}\).  Output: encoder parameters \(\theta\); staypoint representations \(\mathbf{z}_s\).

  1. Offline: build POI sets, spatial and flow grid graphs, and regional semantic vectors on a common grid  ▷ §3.2; no downstream labels used
  2. for epoch \(e=1,\dots,E\) (early stopping):
  3. for each mini-batch of windows \((\mathcal{T},\mathbf{y})\):
  4.  \(\widetilde{\mathcal{T}}\leftarrow\mathcal{A}_{\mathrm{ATR}}(\mathcal{T};\rho)\), \(\rho\in[\rho_{\min},1]\)  ▷ Eq. (12); all terms below use \(\widetilde{\mathcal{T}}\)
  5.  \(\mathbf{m}_i\leftarrow\) Transformer over TCN-smoothed and raw coordinates, \(\Delta t_i\), log-speed  ▷ §3.1
  6.  \(\mathbf{q}_i\leftarrow\Phi_{\mathrm{loc}}(\ell_i)\);  \(\mathbf{g}_i\leftarrow\) query-conditioned composition, scaled by \(\alpha_e\)  ▷ Eqs. (3)–(4), (18)
  7.  \(\mathbf{h}_i\leftarrow\boldsymbol{\alpha}_i\odot\tilde{\mathbf{m}}_i+(1-\boldsymbol{\alpha}_i)\odot\tilde{\mathbf{g}}_i\)  ▷ Eqs. (5)–(6)
  8.  compute CRF emissions, marginals, and \(\mathcal{L}_{\mathrm{dwell}}\); AdamW step on \(\theta\)  ▷ Eqs. (7)–(8), (10)–(17)
  9. Freeze \(\theta\). For each staypoint interval \(s\) (given, or a Viterbi-decoded stop span): \(\mathbf{z}_s\leftarrow\sum_{i\in s}w_i\mathbf{h}_i\)  ▷ Eq. (9)
  10. Train a task-specific head on \(\mathbf{z}_s\) (optionally concatenated with normalized coordinate and temporal features)  ▷ §4
  11. Optional, in a target city with unlabeled trajectories: run Geo-TTST  ▷ Algorithm 2

3.1Motion view

The motion view encodes how the user is moving. A temporal convolutional front-end (four blocks) produces a smoothed coordinate estimate from the input trace. For point \(i\), the motion token combines this estimate with the original coordinates, the elapsed time \(\Delta t_i\), and the log-speed. A two-layer Transformer (\(d_{\mathrm{model}}=256\), eight heads) contextualizes the tokens and outputs \(\mathbf{m}_i\in\mathbb{R}^{256}\). The stream is trained jointly with the pretext and captures velocity changes, temporal persistence, and approach and departure patterns around dwell boundaries.

3.2Place view and query-conditioned composition

The place view builds a point representation from four sources of geographic evidence, assembled offline on a common grid and queried at each point.

  • Geodesic anchor. Sphere2Vec maps longitude and latitude to spherical basis functions at 16 geometrically spaced frequencies; the 48-dimensional basis is projected to a 64-dimensional query \(\mathbf{q}_i=\Phi_{\mathrm{loc}}(\ell_i)\).
  • Functional neighborhood. A KD-tree retrieves up to \(K=20\) POIs within 0.005° of the grid center, in six categories (residential, workplace, restaurant, recreation, education, religion). Each POI token adds a learned type embedding to a multi-scale encoding of its displacement from \(\ell_i\); four-head attention from \(\mathbf{q}_i\) summarizes the set into \(\mathbf{c}^{\mathrm{poi}}_i\in\mathbb{R}^{64}\).
  • Mobility structure. On a 0.005° grid, a spatial graph (eight-neighbor adjacency plus five-nearest-neighbor links in grid-feature space) and a directed flow graph (consecutive transitions observed at least ten times, weights \(\log(1+\text{count})\)) are encoded by separate two-layer GraphSAGE branches, concatenated, and projected to \(\mathbf{c}^{\mathrm{net}}_i\in\mathbb{R}^{64}\). Both graphs are built per city; this is the only city-specific source.
  • Regional semantics. A text description of each cell (coordinates, nearby POI counts, dominant land use) is embedded by a frozen Sentence-BERT encoder (all-MiniLM-L6-v2) and reduced to 64 dimensions by PCA, giving \(\mathbf{c}^{\mathrm{sem}}_i\).

The available tokens form a context bank, and the Sphere2Vec query attends over it:

\[C_i=\big[\mathbf{c}^{\mathrm{poi}}_i;\ \mathbf{c}^{\mathrm{net}}_i;\ \mathbf{c}^{\mathrm{sem}}_i\big],\]
\[\mathbf{g}_i=W_o\,\mathrm{LN}\big(\mathbf{q}_i+\mathrm{MHA}(\mathbf{q}_i,C_i,C_i)\big)\in\mathbb{R}^{128},\]

where \(\mathrm{MHA}\) is four-head attention with query \(\mathbf{q}_i\), \(\mathrm{LN}\) is layer normalization, and \(W_o\) projects to the 128-dimensional place state. A missing source is removed from \(C_i\) rather than replaced by a placeholder; with no external source, \(\mathbf{g}_i\) reduces to the projected Sphere2Vec query. Three of the four sources (Sphere2Vec, POIs, regional semantics) have a common cross-city interface, which is what permits direct transfer (§3.6).

3.3Motion–place gate

The two states differ in dimension and statistics. They are projected into a shared 128-dimensional space and combined by a point-wise, dimension-wise gate:

\[\begin{gathered}\tilde{\mathbf{m}}_i=W_m\mathbf{m}_i,\qquad \tilde{\mathbf{g}}_i=W_g\mathbf{g}_i,\\ \boldsymbol{\alpha}_i=\sigma\big(W_\alpha[\mathbf{m}_i;\mathbf{g}_i]\big),\end{gathered}\]
\[\mathbf{h}_i=\boldsymbol{\alpha}_i\odot\tilde{\mathbf{m}}_i+(1-\boldsymbol{\alpha}_i)\odot\tilde{\mathbf{g}}_i,\]

with \(\mathbf{h}_i,\boldsymbol{\alpha}_i\in\mathbb{R}^{128}\), \(\sigma\) the logistic function, and \(\odot\) the element-wise product. Because \(\boldsymbol{\alpha}_i\) is a vector, some dimensions can follow sharp motion changes while others retain stable functional context. The mean of \(1-\boldsymbol{\alpha}_i\) is reused in §3.6 as a measure of reliance on the place stream.

3.4CRF decoding and staypoint pooling (RQ1, RQ2)

A linear-chain CRF scores a label sequence \(\mathbf{y}\) for trajectory \(\mathcal{T}\) with fused states \(\{\mathbf{h}_i\}_{i=1}^N\):

\[S_\theta(\mathcal{T},\mathbf{y})=\sum_{i=1}^{N}e_\theta(\mathbf{h}_i)_{y_i}+\sum_{i=2}^{N}A_{y_{i-1},y_i},\]

where \(e_\theta(\mathbf{h}_i)\) is the stop/move emission vector and \(A\) the learned transition matrix. The conditional likelihood and per-trajectory negative log-likelihood are

\[\begin{gathered}P_\theta(\mathbf{y}\mid\mathcal{T})=\frac{\exp S_\theta(\mathcal{T},\mathbf{y})}{\sum_{\mathbf{y}'}\exp S_\theta(\mathcal{T},\mathbf{y}')},\\ \mathcal{L}^{(k)}_{\mathrm{CRF}}=-\log P_\theta\big(\mathbf{y}^{(k)}\mid\mathcal{T}^{(k)}\big).\end{gathered}\]

Viterbi decoding turns local evidence into coherent dwell intervals. For an interval \(s\), let \(p_i\) be the CRF marginal probability of stop at point \(i\). The staypoint representation is the marginal-weighted mean of the point states:

\[w_i=\frac{p_i}{\sum_{j\in s}p_j},\qquad \mathbf{z}_s=\sum_{i\in s}w_i\,\mathbf{h}_i\in\mathbb{R}^{128}.\]

The interval \(s\) is either supplied during representation evaluation or taken from a CRF-decoded stop span. \(\mathbf{z}_s\) is the representation consumed by all downstream heads.

3.5Dwell-structured pretraining objective (RQ1)

Sequence level. Long stop interiors would dominate an unweighted CRF loss. The primary term normalizes by valid length and up-weights trajectories that contain move points:

\[\mathcal{L}_{\mathrm{bal\text{-}CRF}}=\frac{1}{|\mathcal{D}|}\sum_{k}\omega_k\,\frac{\mathcal{L}^{(k)}_{\mathrm{CRF}}}{N_k},\]
\[\begin{gathered}\omega_k=1+(w_{\mathrm{move}}-1)\,r_k,\\ r_k=\frac{1}{N_k}\sum_{i}\mathbf{1}\big[y^{(k)}_i=\text{move}\big],\end{gathered}\]

where \(N_k\) is the valid length of trajectory \(k\), \(r_k\) its move-point fraction, and \(w_{\mathrm{move}}=20\).

Observation level. Adaptive trajectory resampling (ATR) keeps an order-preserving random fraction \(\rho\) of observations and recomputes elapsed-time features:

\[\widetilde{\mathcal{T}}=\mathcal{A}_{\mathrm{ATR}}(\mathcal{T};\rho),\qquad \rho\in[\rho_{\min},1].\]

ATR is an augmentation, not a loss: the same ten-minute dwell may be seen every 10 or every 30 seconds, which discourages dependence on one sampling rate. All terms of the full objective are evaluated on \(\widetilde{\mathcal{T}}\):

\[\begin{aligned}\mathcal{L}_{\mathrm{dwell}}=\mathcal{L}_{\mathrm{bal\text{-}CRF}}&+\lambda_{\mathrm{rec}}\mathcal{L}_{\mathrm{rec}}\\&+\lambda_{\mathrm{bnd}}\mathcal{L}_{\mathrm{bnd}}+\lambda_{\mathrm{seg}}\mathcal{L}_{\mathrm{seg}}.\end{aligned}\]

Point level. For the set \(\mathcal{M}\) of masked valid positions, a decoder \(d_\psi\) reconstructs the normalized coordinates \(\bar{\ell}_i\):

\[\mathcal{L}_{\mathrm{rec}}=\frac{1}{|\mathcal{M}|}\sum_{i\in\mathcal{M}}\big\lVert d_\psi(\mathbf{h}_i)-\bar{\ell}_i\big\rVert_2^2.\]

Transition level. For the sparse set \(\mathcal{B}=\{i:y_i\neq y_{i-1}\}\) of labeled arrival and departure points,

\[\mathcal{L}_{\mathrm{bnd}}=-\frac{1}{|\mathcal{B}|}\sum_{i\in\mathcal{B}}\log P_\theta(y_i\mid\mathcal{T})_i.\]

Segment level. For each ground-truth dwell span \(s\in\mathcal{S}\), let \(p_i=P_\theta(y_i=\text{stop}\mid\mathcal{T})\) and let \(\widehat{\ell}_i\) be the predicted coordinate. The probability-weighted and geometric centroids are

\[\mu^{p}_s=\frac{\sum_{i\in s}p_i\,\widehat{\ell}_i}{\sum_{i\in s}p_i},\qquad \mu_s=\frac{1}{|s|}\sum_{i\in s}\widehat{\ell}_i,\]

and the segment term aligns them while penalizing the mean stop probability \(\bar{p}_{\partial s}\) in the region just outside the span:

\[\mathcal{L}_{\mathrm{seg}}=\frac{1}{|\mathcal{S}|}\sum_{s\in\mathcal{S}}\Big[\big\lVert\mu^{p}_s-\mu_s\big\rVert_1+\beta\,\bar{p}_{\partial s}\Big].\]

The four terms model sequence coherence, point-level geometry, motion transitions, and complete dwell structure, respectively.

GeoContext warmup. To keep uncalibrated place features from dominating early training, the place state is scaled at epoch \(e\) by

\[\alpha_e=\min\!\Big(0.01+0.99\,\frac{e}{20},\ 1\Big).\]

This is an optimization schedule, not part of the representation.

3.6Cross-city adaptation: Geo-TTST (RQ3)

Direct transfer. The source-pretrained model is applied to a target city with no target labels. The mobility-graph token is omitted when no compatible target graph exists, and any other missing source is removed from \(C_i\) in Eq. (3).

Geo-conditioned confidence. When unlabeled target windows \(\mathcal{D}_t=\{\mathcal{T}_j\}\) are available, Geo-TTST self-trains on confident pseudo-labels. Predictive confidence alone can be unreliable under geographic shift, so it is combined with the place-reliance signal from the gate. In round \(r\), with CRF marginal \(p^{(r)}_{j,i}(y)\) and gate \(\boldsymbol{\alpha}^{(r)}_{j,i}\),

\[\begin{gathered}\hat{y}^{(r)}_{j,i}=\arg\max_{y}\,p^{(r)}_{j,i}(y),\\ a^{\mathrm{geo},(r)}_{j,i}=\operatorname{mean}_d\big(1-\alpha^{(r)}_{j,i,d}\big),\end{gathered}\]
\[c^{(r)}_{j,i}=\gamma\,\max_{y}\,p^{(r)}_{j,i}(y)+(1-\gamma)\,a^{\mathrm{geo},(r)}_{j,i},\]

where \(\gamma\in[0,1]\) balances predictive certainty against geographic support. With \(v_{j,i}\in\{0,1\}\) marking valid, non-padded points, the selected set is

\[\mathcal{I}^{(r)}=\big\{(j,i):\ c^{(r)}_{j,i}>\tau,\ v_{j,i}=1\big\}.\]

Restricted update. The motion encoder, GeoContext encoder, and fusion module are frozen; only the CRF parameters \(\theta_{\mathrm{CRF}}\) are updated. Because confidence filtering can keep non-contiguous points, the loss uses the differentiable CRF marginals at the selected points instead of a full-sequence likelihood:

\[\mathcal{L}^{(r)}_{\mathrm{TTST}}=-\frac{1}{|\mathcal{I}^{(r)}|}\sum_{(j,i)\in\mathcal{I}^{(r)}}\log p_{\theta_{\mathrm{CRF}}}\big(\hat{y}^{(r)}_{j,i}\mid\mathcal{T}_j\big)_i.\]

Updating only the CRF head recalibrates stop/move decoding without overwriting \(\mathbf{h}_i\). Target stop/move labels are never passed to the model and are used only for offline evaluation.

Algorithm 2  CRF-only Geo-Conditional Test-Time Self-Training

Input: source-pretrained \(\theta=(\theta_{\mathrm{enc}},\theta_{\mathrm{fuse}},\theta_{\mathrm{CRF}})\); unlabeled target windows \(\mathcal{D}_t\); rounds \(T\), update epochs \(K\), threshold \(\tau\), weight \(\gamma\), learning rate \(\eta\).  Output: adapted \(\theta_{\mathrm{CRF}}\).

  1. Omit geographic sources unavailable in the target domain; freeze \(\theta_{\mathrm{enc}}\) and \(\theta_{\mathrm{fuse}}\)
  2. for \(r=1,\dots,T\):
  3. evaluation mode: for each target mini-batch, compute marginals \(p^{(r)}\), gates \(\boldsymbol{\alpha}^{(r)}\), and valid mask \(v\)  ▷ Eq. (8)
  4.  set \(\hat{y}^{(r)}_{j,i}\) and \(c^{(r)}_{j,i}\);  \(\hat{m}^{(r)}_{j,i}\leftarrow\mathbf{1}[c^{(r)}_{j,i}>\tau]\,v_{j,i}\)  ▷ Eqs. (19)–(21)
  5. training mode: for \(k=1,\dots,K\), for each shuffled target mini-batch:
  6.  recompute CRF marginals with the current \(\theta_{\mathrm{CRF}}\); skip the batch if it has no selected points
  7.  compute \(\mathcal{L}^{(r)}_{\mathrm{TTST}}\); update only \(\theta_{\mathrm{CRF}}\) with AdamW  ▷ Eq. (22); pseudo-labels fixed within the round
  8. return \(\theta_{\mathrm{CRF}}\)

The reported Atlanta configuration uses \(T=3\) rounds, \(K=1\) update epoch per round, \(\tau=0.95\), \(\gamma=0.5\), learning rate \(5\times10^{-5}\), batch size 32, AdamW weight decay \(10^{-4}\), and gradient-norm clipping at 1.0, with the city-specific road graph disabled.

4Experimental protocol

Table 2. Settings, data, tasks and metrics, and comparisons. All datasets use agent-disjoint 70/15/15 train/validation/test splits.
SettingDataTasks and metricsCompared against
Pretraining and pretext checkSF-LIFE: 1,000 agents from the public 500K-agent, 70-day corpus, resampled from 5 s to 10 s; 512-point windows, stride 256Point macro F1 (stop/move); segment precision/recall/F1 with 0.001° (∼111 m) and 5 min tolerancesGround-truth stop/move labels
In-domainSF-LIFEHome/Work (three-class macro F1), Activity (six-class macro F1), Anomaly (AUROC), Duration (MAE, min), NextActivity (macro F1), NextLocation (Top-1, Top-5, Acc@500 m, Acc@1 km); Trajectory User Linking (Top-1, Top-5) as a diagnosticTask-specific baselines (MLPs on conventional features; Markov or frequency models); TS2Vec, TrajCL, START, MTM with the same probes
Cross-region transferAtlanta: 500 agents, 30 days, ∼22M GPS pointsSame tasks and metrics as in-domain; NextLocation with a hybrid head (transition, frequency, recency, distance priors)Feature-only and task-specific baselines; public methods transferred from SF-LIFE and trained on Atlanta; Atlanta-trained StayBERT
Cross-dataset transferGeoLife: 177 users, 19,372 derived staypointsHome/Work, Activity, NextActivity, Anomaly, Duration (NextLocation excluded: candidate identities are dataset-specific)GeoLife feature-only; TS2Vec, TrajCL, START, MTM

The encoder is frozen for all downstream tasks; Atlanta and GeoLife labels train only the heads and are mapped to the six-class SF-LIFE venue schema. For the four tabular tasks and NextActivity, a “+ raw” variant concatenates normalized coordinate and temporal features with the embeddings; this is not used for NextLocation. Pretraining uses AdamW, batch 128, at most 30 epochs with patience 5, learning rate \(2\times10^{-3}\) (\(2\times10^{-4}\) for GeoContext), weight decay \(10^{-4}\), a three-epoch learning-rate warmup, and the 20-epoch GeoContext warmup of Eq. (18).

5Results

5.1Pretext learning (RQ1)

Table 3. Staypoint detection on SF-LIFE (pretext sanity check). Macro F1, precision, recall ↑. Thresholds selected on validation (confidence 0.65, boundary 0.6, minimum duration 300 s) and fixed for test.
MetricValue
Validation point macro F10.9924
Test point macro F10.9929
Test segment precision / recall / F10.9993 / 0.9986 / 0.9990
Detected / ground-truth segments25,864 / 25,880

Finding. The pretext is learned almost exactly: test point macro F1 is 0.9929 and segment F1 is 0.9990, with 25,864 segments detected against 25,880 in the ground truth. In a controlled diagnostic, removing the GeoContext warmup of Eq. (18) lowers validation F1 from 0.9836 to 0.4966 and segment F1 from 0.5538 to 0.0095. These numbers verify the pretext only; the evidence for the representation is the downstream transfer below.

5.2In-domain multi-task evaluation (RQ2)

Table 4. SF-LIFE, frozen encoders with matched task-specific heads. Duration is MAE in minutes ↓; all other metrics ↑. StayBERT NextLocation (NL) uses a hybrid head with transition, recency, frequency, and distance priors. “–”: not evaluated. Best in bold.
MethodHW↑Act.↑NAct.↑Anom.↑Dur.↓NL@1↑NL@5↑NL@500m↑NL@1km↑
Task-specific baseline0.67650.59160.16930.7269262.70.48660.72400.50280.5409
TS2Vec0.64020.57780.23400.7156109.20.38000.70630.40230.4600
TrajCL0.63940.57970.26570.714494.30.38640.72120.41220.4723
START0.69290.59640.30280.723064.80.42600.72210.47680.5335
MTM0.71930.62100.31520.7195154.30.24860.45200.29910.3941
StayBERT (frozen)0.71060.60360.31560.760369.60.45480.73600.44230.4867
StayBERT + raw0.72800.59660.30980.740886.5––––

Finding. StayBERT is first or second on seven of nine metrics. The frozen representation is best on NextActivity (0.3156), Anomaly (0.7603 against 0.7269 for the task baseline), and NextLocation Top-5 (0.7360); adding raw features gives the best Home/Work F1 (0.7280) but lowers NextActivity to 0.3098. It is not best on Activity (MTM, 0.6210 against 0.6036), Duration (START, 64.8 against 69.6 min), or NextLocation Top-1, 500 m, and 1 km, where the task-specific baseline leads (for example 0.4866 against 0.4548 Top-1).

5.3Cross-city and cross-dataset transfer (RQ3)

Three StayBERT configurations are evaluated on Atlanta: direct transfer of the SF-LIFE encoder with no parameter updates and the road graph disabled; direct transfer followed by Geo-TTST (Algorithm 2); and an Atlanta-trained reference with the same architecture and hyperparameters.

Table 5. SF-LIFE → Atlanta, tabular probes. HW, Act. macro F1 ↑; Anom. AUROC ↑; Dur. MAE in minutes ↓. “+ raw” adds spatiotemporal features to the frozen embeddings; Atlanta-trained rows are same-city references. Best in bold.
SettingHW↑Act.↑Anom.↑Dur.↓
Atlanta baseline
Feature-only0.64000.92590.8352163.6
Public methods, SF-LIFE → Atlanta
TS2Vec0.51530.67120.8855186.9
TrajCL0.50790.58880.8911211.3
START0.54540.66200.903495.0
MTM0.52090.58060.9050204.5
Public methods, Atlanta-trained
TS2Vec0.52260.64270.8909179.2
TrajCL0.53080.62510.8843202.1
START0.60260.70790.8957102.1
MTM0.52300.59260.902483.7
StayBERT
Direct transfer0.72560.89800.905980.8
Direct + Geo-TTST0.70280.90300.916679.4
Direct + raw0.74810.88130.943076.4
Atlanta-trained0.73110.89980.903894.0
Atlanta-trained + raw0.80460.95790.940082.0

Finding. Direct transfer is the strongest source-pretrained model on all four probes (HW 0.7256 against 0.5454 for START; Duration 80.8 against 95.0 min). It nearly matches Atlanta-trained StayBERT on Home/Work (0.7256 against 0.7311) and Activity (0.8980 against 0.8998) and is better on Anomaly and Duration (80.8 against 94.0 min). Adding raw features gives the best Anomaly (0.9430) and Duration (76.4) but lowers Activity to 0.8813. Geo-TTST changes are small and mixed (Home/Work −0.0228, Anomaly +0.0107). The best Home/Work and Activity scores come from the Atlanta-trained model with raw features, and the Atlanta feature-only baseline (0.9259) exceeds direct transfer on Activity.

Table 6. SF-LIFE → Atlanta, sequential probes. NAct macro F1 ↑; NextLocation accuracy ↑ (hybrid head with transition, frequency, recency, and distance priors). n/a: outside a baseline’s target. Best in bold.
SettingNAct↑NL@1↑NL@5↑NL@500m↑NL@1km↑
Task-specific baselines
NAct majority0.2514n/an/an/an/a
NAct Markov0.2514n/an/an/an/a
NL frequencyn/a0.36360.90990.40760.5290
NL Markovn/a0.57250.92060.60500.6662
Public methods, SF-LIFE → Atlanta
TS2Vec0.54320.58020.96020.62550.7124
TrajCL0.48780.59350.96780.62750.7207
START0.60320.75970.97040.78100.8371
MTM0.51690.33260.95420.41850.5370
Public methods, Atlanta-trained
TS2Vec0.49660.56640.93810.59740.6792
TrajCL0.50020.55680.95330.61050.6858
START0.58300.65830.91390.68620.8333
MTM0.64380.30340.92080.39200.5164
StayBERT
Direct transfer0.68470.68220.95870.70990.7591
Direct + Geo-TTST0.71090.75440.98020.78620.8032
Atlanta-trained0.65990.67990.95980.71070.7606

Finding. Direct transfer reaches 0.6847 NextActivity F1, against 0.2514 for the task-specific baselines and 0.6599 for Atlanta-trained StayBERT; Geo-TTST raises it to 0.7109, the best result. For NextLocation, Geo-TTST is best on Top-5 (0.9802) and 500 m accuracy (0.7862) and close to START on Top-1 (0.7544 against 0.7597), while transferred START keeps the best 1 km accuracy (0.8371 against 0.8032). On sequential tasks Geo-TTST gives consistent gains over direct transfer, unlike on the tabular probes.

Table 7. Trajectory User Linking diagnostic under a temporal weekly closed-set split. Accuracy (%) ↑. Best in bold.
ConfigurationTop-1↑Top-5↑UsersSequences
SF-LIFE frozen0.10.69032270
SF-LIFE → Atlanta0.21.0500500
Atlanta-trained reference85.494.8500500

Finding. User identity is not recoverable from the transferred representation: frozen SF-LIFE embeddings stay at chance level (0.1% Top-1 for 903 users; 0.2% after transfer to 500 Atlanta users), while the Atlanta-trained reference reaches 85.4% Top-1. User linking depends on target-specific spatial signatures and repeated routines, which marks a boundary of cross-region transfer.

Table 8. SF-LIFE → GeoLife. HW, Act., NAct macro F1 ↑; Anom. AUROC ↑; Dur. MAE in minutes ↓. StayBERT and feature-only rows use 19,372 staypoints; public baselines use 19,338 embeddings. “–”: not evaluated. Best in bold.
MethodHW↑Act.↑NAct↑Anom.↑Dur.↓
GeoLife feature-only0.26100.21420.27030.800265.1
TS2Vec0.33780.23440.16740.671659.3
TrajCL0.33400.21760.25310.685758.6
START0.32020.22980.23520.672958.3
MTM0.34010.22500.16740.676259.0
StayBERT0.34170.24880.27050.773958.4
StayBERT + raw0.33460.2473–0.776858.3

Finding. Frozen StayBERT is best on Home/Work, Activity, and NextActivity, with the largest gain on Home/Work over the feature-only baseline (0.3417 against 0.2610); the margins over the strongest public method are small (0.3417 against 0.3401 for MTM) and NextActivity is effectively tied with feature-only (0.2705 against 0.2703). Anomaly detection is dominated by target-domain statistics: the feature-only baseline leads (0.8002 against 0.7768 with raw features). StayBERT with raw features ties START on Duration (58.3 min). Raw features change the transferred scores only marginally, so the gains come from the frozen representation.

5.4GeoContext ablations (RQ4)

Table 9. GeoContext ablations, pretrained on SF-LIFE and evaluated on Atlanta (values from Figure 2 of the paper). Duration MAE in minutes ↓; all other metrics ↑. NextLocation uses an embedding-only head and is not comparable to Table 6. Best in bold.
MetricFull−POI−LLM−Road GNNGrid coords
Semantic
HW (F1) ↑0.72560.71030.57190.62290.5514
Activity (F1) ↑0.89800.86640.68540.79600.5950
Behavioral / temporal
NAct (F1) ↑0.68470.66350.53470.72600.5747
Anomaly (AUROC) ↑0.90590.90120.90760.90690.9047
Duration (MAE) ↓80.8166.7100.870.690.7
Embedding-only NextLocation
NL@1 ↑0.61090.29240.50330.53590.6000
NL@5 ↑0.93820.89700.95860.92920.9440
NL@500m ↑0.58860.32550.55290.56570.6293
NL@1km ↑0.70890.47270.64420.63490.6839

Finding. Under transfer, the full model is best on Home/Work, Activity, NextLocation Top-1, and 1 km accuracy. Removing POIs degrades every metric and roughly doubles Duration MAE (80.8 → 166.7 min, −106.3%). Removing regional semantics costs 21.2% on Home/Work and 23.7% on Activity but slightly helps Anomaly and NextLocation Top-5. Removing the road graph improves NextActivity (0.7260) and Duration (70.6 min) at the expense of most other tasks. Replacing continuous coordinates with grid coordinates gives the best 500 m accuracy (0.6293) but lowers Activity by 33.7%. No single source ordering holds across tasks.

Table 10. GeoContext ablations, source-domain probing on SF-LIFE (supplement). Duration MAE in minutes ↓; all other metrics ↑. NL uses an embedding-only head, so NL values differ from Table 4. Best in bold.
ConfigurationHW↑Act.↑NAct.↑Anom.↑Dur.↓NL@1↑NL@5↑NL@500m↑NL@1km↑
StayBERT (full)0.71060.60360.31560.760369.60.33880.55290.35510.4776
−POI0.69660.61190.30670.7244167.30.29610.49150.32930.4101
−LLM0.70230.50890.30290.7294127.90.28790.28180.21300.2901
−Road GNN0.73410.59150.31720.725271.50.27310.59540.30380.4106
Grid coordinates0.70040.57230.29660.7274115.10.33030.57220.35140.4049

Finding. In the source domain the full model is best on five of nine metrics (Anomaly 0.7603, Duration 69.6 min, and NextLocation Top-1, 500 m, and 1 km) and second on Home/Work, Activity, and NextActivity. Removing the road graph gives the best Home/Work (0.7341), NextActivity (0.3172), and Top-5 (0.5954). Removing POIs slightly improves Activity (0.6119) but raises Duration MAE to 167.3 min, and removing regional semantics drops NextLocation Top-5 from 0.5529 to 0.2818.

Citation

@misc{bao2026staybert,
  title  = {StayBERT: Staypoint Detection as the Pretext Task for Trajectory Foundation Models},
  author = {Bao, Riyang and Tian, Mingke and Z{\"u}fle, Andreas and Zhao, Liang},
  year   = {2026},
  note   = {Under review}
}

Key references

  1. D. Ashbrook and T. Starner. Using GPS to Learn Significant Locations and Predict Movement Across Multiple Users. Personal and Ubiquitous Computing 7(5), 2003.
  2. J. Lafferty, A. McCallum, and F. Pereira. Conditional Random Fields: Probabilistic Models for Segmenting and Labeling Sequence Data. ICML, 2001.
  3. G. Mai, Y. Xuan, W. Zuo, et al. Sphere2Vec: A General-Purpose Location Representation Learning over a Spherical Surface for Large-Scale Geospatial Predictions. ISPRS Journal of Photogrammetry and Remote Sensing 202, 2023.
  4. W. L. Hamilton, R. Ying, and J. Leskovec. Inductive Representation Learning on Large Graphs. NeurIPS, 2017.
  5. J. Jiang, D. Pan, H. Ren, X. Jiang, C. Li, and J. Wang. Self-Supervised Trajectory Representation Learning with Temporal Regularities and Travel Semantics. ICDE, 2023.
  6. D. Wang, E. Shelhamer, S. Liu, B. Olshausen, and T. Darrell. Tent: Fully Test-Time Adaptation by Entropy Minimization. ICLR, 2021.