arXiv:2610.35190cs.LGOct 2026

Manuscript Offprint

arXiv:2610.35190

LEAP: a Latent Embedding Anomaly Patch-Transformer for time-series anomaly detection

Cristhian Moya-Mota, Ignacio Aguilera-Martos, Diego García-Gil, Julián Luengo

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Time-series anomaly detection is dominated by reconstruction-based neural detectors, whose objective is structurally flawed. Since the target is also the input, an expressive model can learn to reconstruct anomalies too, leaving uninformative residuals. Recent large-scale benchmarks show that, on curated data, elaborate deep detectors rarely beat simple statistical baselines, while current leaders rely on representation learning. We propose LEAP (Latent Embedding Anomaly Patch-Transformer), which combines masked prediction with latent representation-based anomaly evidence, without relying on reconstruction or attention-based scoring. The model removes patches from a window and predicts them from the remaining temporal and cross-channel context, so prediction errors measure how well learned dynamics explain hidden segments. Deterministic complementary group masking ensures every time step is scored while hidden, with identical visible fractions during training and inference. LEAP adds three label-free evidence sources: latent-embedding novelty calibrated by local density, local temporal contrast, and per-channel novelty pooled over channels selected by six label-free criteria. Under the TSB-AD protocol, the full model achieves a VUS-PR of 0.5179±0.00220.5179 \pm 0.0022 on 180 held-out multivariate series. On TSB-AD-U, a univariate variant combining multi-scale masked-prediction scoring with latent novelty, without contrast or channel-pool novelty, achieves 0.6194±0.00160.6194 \pm 0.0016 on 350 held-out series. Both results average three random seeds. A five-stage ablation on TSB-AD-M, supported by paired Wilcoxon signed-rank tests, shows statistically significant gains from each successive component.

Keywords Anomaly detection; Time series; Masked modeling; Self-supervised learning; Representation learning; Benchmarking

1 Introduction

Time-series anomaly detection (TSAD) is the task of deciding, for every instant of a recorded signal, whether the behavior observed there is compatible with the process that produced the rest of the signal [1]. It underpins condition monitoring in industrial plants, fault diagnosis in spacecraft telemetry, intrusion detection in cyber-physical systems, arrhythmia screening in electrocardiography, and the operation of large software systems that must detect failures before their users do [2].

What distinguishes it from anomaly detection on unordered data is that the unit of analysis is rarely a single sample. Normality depends on temporal context, which encompasses periodicity, trend, and regime. As a result, a value that is unremarkable at one phase of a cycle can become pathological shortly thereafter, indicating that the true object of abnormality is usually a subsequence: a deformed heartbeat with the same mean, variance and range as a healthy one, a sustained shift of a sensor's operating level, a burst of variance, or a configuration of channels that is impossible jointly even though each channel is plausible on its own [3]. Labels are scarce and unbalanced, the catalog of anomaly types is heterogeneous enough that a detector tuned for spikes fails on level shifts, and evaluation has to credit a detection that is correct in substance but a few samples early or late.

The families of methods addressing this task have accumulated rather than replaced one another. The earliest fit a model to the series and inspect its residuals, from ARIMA and exponential smoothing onwards [4]. A second embeds the series into a space of sliding windows and identifies windows that are dissimilar to the rest, with the time-series discord providing the canonical formulation [5]. A third learns a predictor of future values with a neural network and scores forecast residuals [6]. A fourth, dominant for much of the last decade, reconstructs its input and flags large reconstruction errors as anomalies [7], while a fifth learns short-subsequence representations through self-supervision and detects anomalies by their distance to normal representations [8].

Given its prevalence, the reconstruction family warrants closer examination. A key limitation of this approach is that the target is also used as input, a characteristic that cannot be fully addressed through architectural refinements alone. A model with enough capacity can learn the identity map, and what it copies includes the anomalies. The very property that makes a network expressive enough to represent complex normal dynamics is the property that lets it reproduce the abnormal ones. Practical systems compensate by integrating additional evidence into the score, such as inter-channel structure terms, amplitude statistics, hand-crafted shape metrics, and association discrepancies, thereby tacitly admitting that the residual alone does not carry the information the detector needs.

The practical significance of this issue is well established. Wu [9] demonstrated that standard benchmark datasets are severely compromised by triviality, mislabeling, and run-to-failure bias. Kim [10] showed that the widely used point-adjust protocol is sufficiently permissive for random scores to outperform published detectors. Schmidl [11] and, more recently, Liu [12] re-ran dozens of algorithms under controlled conditions and reached a conclusion that should reorganize the research agenda: simple architectures generally match or beat elaborate designs, and no single method dominates across data sources. The numbers are blunt. On the multivariate track of TSB-AD, which curates 1,070 manually inspected series across 40 datasets and reports VUS-PR [13] as its primary measure, the best-performing Transformer detector is TranAD at 0.18 VUS-PR, while Anomaly Transformer and DCdetector, the two most cited Transformer detectors in the field, achieve scores of 0.12 and 0.09, respectively, falling below the 0.20 of an Isolation Forest and far below the 0.31 of a plain convolutional forecaster [12].

Since then, the immediate context of this work has shifted. A new class of detectors has raised the multivariate state of the art from the 0.31–0.35 range to approximately 0.48 VUS-PR, largely by learning representations of short subsequences and scoring test windows by their distance to normal ones. VACE follows this principle and reaches 0.48 VUS-PR [14], while PaAno reaches 0.43 using nearest-neighbor scoring over learned patch representations [8]. KAN-AD [15] achieves 0.41 through Fourier-based temporal modeling, while CrossAD [16] reaches 0.33 using cross-scale reconstruction and cross-window context. Thus, the recent shift has been away from reconstruction-based Transformers toward representation learning with distance-based scoring. This convergence motivates our design, which combines a masked-prediction backbone with the same family of scoring rules.

Rather than mitigating the limitations of reconstruction-based detection, this paper addresses their underlying cause. We present LEAP (Latent Embedding Anomaly Patch-Transformer), a semi-supervised detector whose base objective is predict-from-context rather than standard reconstruction. In this approach, the input window is divided into fixed-length patches across the temporal and channel dimensions. A deterministic subset of these patches is replaced by a learned mask embedding, requiring the network to predict the missing content using the remaining temporal and cross-channel context. As the masked patch is not visible to the encoder, the model cannot simply copy its content during reconstruction. Therefore, a large prediction error indicates that the observed context and the learned normal dynamics of the series are insufficient to explain the hidden values. Because the masking groups form an exact partition of the patch grid, every time step is predicted exactly once and always from context, and because a single group is masked both during training and during scoring, there is no distribution shift between how the model was trained and how it is used.

The second contribution addresses the structural limitations of masked prediction error, which may miss sustained level shifts and globally novel but locally predictable patterns. LEAP first combines masked prediction error with local moments to capture level shifts (Stage 1), then adds three complementary sources of label-free evidence: (i) density-calibrated latent-window novelty (Stages 2–3); (ii) local temporal contrast to improve precision in non-stationary recordings (Stage 4); and (iii) per-channel novelty over channels selected by six label-free criteria (Stage 5). Their additive fusion preserves complementary anomaly evidence. The five-stage ablation evaluates density calibration separately from the latent novelty it refines, rather than treating it as an additional evidence source.

The contributions of this work are the following.

  1. A masked-modeling detector for multivariate time-series anomaly detection, implemented over a Transformer encoder, with a deterministic complementary group masking scheme that staggers holes across channels, so that a broken inter-channel relationship surfaces in the same error signal as a deformed waveform or a level shift, with no hand-crafted structural metric (Sections 3.3–3.4).

  2. A factorized temporal/channel encoder with an optional latent bottleneck on the channel axis, which reduces the cost of the cross-channel route from O(C2)\mathcal{O}(C^{2}) to O(CK)\mathcal{O}(CK) making hundreds of channels affordable (Section 3.3).

  3. A label-free scoring pipeline (comprising per-channel error calibration with a spread floor, soft channel aggregation, edge-weighted overlap-add, event-scale smoothing, and tolerance dilation) alongside three additive evidence layers: density-calibrated latent k-nearest-neighbor novelty, local contrast, and criterion-based per-channel novelty (Sections 3.6–3.7.4).

  4. A five-stage decomposition of the model that doubles as a controlled ablation, where each stage is a strict extension of the previous one and reduces to it exactly by setting a single coefficient to zero (Section 3.7).

  5. An evaluation under the TSB-AD protocol on 180 multivariate and 350 univariate held-out series, with VUS-PR as the primary measure, paired Wilcoxon signed-rank tests for every increment, and full disclosure of the tuning procedure (Sections 4 and 5).

The remainder of the paper is organized as follows. Section 2 reviews the foundations of TSAD, major methodological families, and current benchmarking evidence. Section 3 introduces the proposed LEAP framework. Section 4 details the experimental setup, and Section 5 presents and discusses the results. Finally, Section 6 concludes this manuscript.

References (53)