Supervision Recovery for Time Series Anomaly Detection via Context-Anchored Pairing

Yifei Gao, Tian Lan, Yimeng Lu, Xuming An, Meng Wang, Wenjun He, Yijie Li, Chen ZhangNeurIPS 2026

TL;DR

Spotting anomalies in time-series data without labels is notoriously tricky because what looks like a glitch during steady-state operation might be completely normal during a system boot-up. This paper introduces CAPS (Context-Anchored Pair Supervision), a framework that extracts the abstract "essence" of anomalies from simulated data and realistically grafts them onto unlabeled real-world sequences. By pairing each normal trajectory with its newly generated anomalous twin, CAPS gives simple detectors crisp, context-aware supervision—no real-world anomaly labels required.

What Problem Does This Paper Address?

In Time Series Anomaly Detection (TSAD), labeled anomalies are rare, and context is everything. Because you usually only have unlabeled (mostly normal) data, standard methods try to learn what "normal" looks like—via forecasting or reconstruction—and flag anything surprising. Alternatively, some methods inject synthetic, rule-based glitches into normal data to train a classifier.

The catch? Rule-based perturbations often look artificial and ignore the underlying physics or dynamics of the sequence. You could use rich simulated datasets where you have exact pairs of normal and anomalous behavior, but you can't just train on simulated anomalies directly—your detector will get confused by the background differences between the simulation and your real target domain. Even copying the raw difference (the residual) from a simulation onto real data fails, because the exact same anomaly mechanism manifests differently depending on the current state of the system.

Matched-supervision view of temporal anomalies

The authors ask: What if we could recover ideal supervision—seeing both the normal outcome and the anomalous outcome under the exact same real-world context—without any target-domain labels?

Methods

CAPS bridges the gap between structured simulations and unlabeled target data in three main stages, using standard Temporal Convolutional Networks (TCNs) as backbones alongside a novel training and generation pipeline:

Overview of the CAPS framework
  1. Structured Disentanglement via Counterfactual Swapping: Starting with simulated normal–anomalous pairs, a shared TCN encoder splits sequences into two latent codes: temporal structure ($z_s$, the background context) and anomaly semantics ($z_a$, what kind of glitch is happening). What's clever here is a counterfactual recombination loss: the model swaps the structure code of an anomalous sequence with the structure code of its normal twin, forcing the decoder to reconstruct the exact anomaly using clean, normal context. This ensures $z_a$ captures pure, transferable anomaly meaning without leaking background dynamics.
  2. Context-Conditioned Residual Diffusion: Next, CAPS fits a Gaussian mixture prior over the learned $z_a$ space, grouped into $K=3$ coarse anomaly families (point, periodic, and trend). To realize an anomaly on a real target sequence, CAPS uses a hard-routed Mixture-of-Experts (MoE) conditional diffusion model. Instead of generating a whole new sequence, each expert generates a residual effect ($\hat{r}$) conditioned on the real target's structure code ($z_s^{\text{tar}}$), a sampled anomaly code ($\tilde{z}_a$), and a binary time-mask ($m$) indicating where the anomaly should occur.
  3. Target-Reference Pairing: Adding this tailored residual to the real target sequence ($x^{\text{tar}} + \hat{r}$) creates a context-anchored anomalous counterpart. Now having matched pairs with exact point-wise labels ($0$ for the original, $m$ for the counterpart), the authors train an independent, lightweight TCN classifier using standard binary cross-entropy. (An optional variant, CAPS(Diagnosis), uses a tiny set of known anomalies solely to route and narrow down which expert modes to sample from).

Datasets

No new real-world benchmarks are introduced. Instead, CAPS learns transferable priors from simulated normal–anomalous pairs (generated following a prior synthetic procedure covering point, periodic, and trend families) and evaluates on nine diverse public TSAD benchmarks: IOPS, MGAB, NAB, Power, SED, UCR, NEK, TODS, and YAHOO.

Key Insights and Ideas

  • Anomalies are context-dependent operators, not static shapes: The paper's core "aha" moment is treating an anomaly not as an additive sticker you slap onto a graph, but as a semantic concept that interacts with local dynamics. Visualizations in the paper show that feeding the exact same semantic code $z_a$ into different target trajectories yields noticeably different, context-appropriate wave distortions.
  • Matching the background isolates the signal: When you shuffle CAPS's generated residuals and apply them to the wrong target sequences, performance drops sharply (Affiliation-F falls from 85.33 to 79.27). Having an exact shared background forces the downstream detector to focus strictly on anomaly-induced variations.
  • Generating residuals beats generating whole sequences: Asking the diffusion model to predict only the difference ($\hat{r}$) rather than synthesizing the entire anomalous sequence from scratch preserves the target sequence's subtle quirks outside the anomaly window, boosting F1$_T$ from 40.96 to 46.53.

Key Results

Across the nine benchmarks and four evaluation metrics (Affiliation-F, F1$_T$, Standard-F1, and VUS-PR), CAPS takes first place in 26 out of 36 dataset–metric combinations (and top-two in 35/36), achieving an average rank of 1.32.

  • Aggregate Scores: CAPS hits 85.33 on Affiliation-F, 46.53 on F1$_T$, 42.91 on Standard-F1, and 46.82 on VUS-PR.
  • Beating Naive Injection & Supervision: Using the exact same lightweight TCN detector backbone, CAPS substantially outperforms standard anomaly injection (TCN-Injection: 80.30 Aff.-F, 36.66 F1$_T$, 33.87 VUS-PR) and direct source-residual copy-pasting (81.58 Aff.-F, 43.16 F1$_T$). Strikingly, under the evaluated protocol, it even outperforms TCN-Supervised (78.72 Aff.-F, 31.34 F1$_T$), demonstrating how rich, dense synthetic pairs can trump scarce real-world labels.

Limitations and Future Work

  • Prior Coverage: CAPS is only as imaginative as its simulation prior. If a real-world system fails in a bizarre way not spanned by the simulated semantic space, supervision recovery may miss it. Developing richer, adaptive priors is a key next step.
  • Cross-Variable Dependencies: The current framework focuses strictly on temporal behavior (patterns over time within windows) without explicitly modeling correlations across multiple sensors or variables—leaving multivariate interaction anomalies as an important avenue for future work.
  • Reference Contamination: Both the method and theoretical risk bounds assume the unlabeled target training data is mostly normal; heavy contamination from unlabeled anomalies acting as "normal" anchors isn't explicitly mitigated.

Summary updated

Abstract

Time series anomaly detection (TSAD) remains challenging not only because anomaly labels are scarce, but also because temporal anomalies are highly context-dependent. Existing methods often rely on unsupervised objectives or surrogate abnormal patterns, providing limited supervision for context-dependent normal--anomalous distinctions. We propose Context-Anchored Pair Supervision (CAPS), a supervision-recovery framework for TSAD. CAPS views ideal anomaly supervision as a matched comparison between normal and anomalous outcomes under the same temporal context, and seeks to recover such supervision without target-domain anomaly labels. Using simulated normal--anomalous pairs, CAPS learns structure and anomaly-semantic representations through reconstruction, background consistency, and within-pair counterfactual recombination. The resulting anomaly representations form a continuous semantic space with coarse modes and induce a sampleable multimodal prior. CAPS conditionally realizes sampled semantics as residual-form effects on target reference trajectories. The resulting context-anchored normal--anomalous counterparts provide temporal supervision for discriminative detector learning. Experiments on nine datasets show that CAPS achieves the strongest aggregate performance across all four evaluation metrics among the compared methods, while complementary ablations and transfer analyses support the roles of context anchoring, semantic disentanglement, and conditional realization.
BibTeX
@inproceedings{gao2026supervision,
  author = {Yifei Gao and Tian Lan and Yimeng Lu and Xuming An and Meng Wang and Wenjun He and Yijie Li and Chen Zhang},
  title = {{Supervision Recovery for Time Series Anomaly Detection via Context-Anchored Pairing}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=YqBYI9KKtm},
}
Figure