Residual-Tail-Informed Flow Matching for Time Series Anomaly Detection

Shyam Sundar Saravanan, Tie Luo, Sanjay MadriaarXiv 2026 · arXiv

TL;DR

Standard anomaly detection models often fail by flagging rare but perfectly valid "normal" behaviors as anomalies. This paper introduces RT-FM, a two-stage framework that uses a temporal VAE to identify these underrepresented patterns and then applies a "residual-tail" weighting strategy to train a high-performance Flow Matching detector, significantly reducing false alarms.

What Problem Does This Paper Address?

In Time Series Anomaly Detection (TSAD), we usually train a model on "nominal" (normal) data. The goal is for the model to learn the distribution of normal behavior so it can flag anything that deviates from it.

However, there is a catch: nominal behavior is rarely homogeneous.

Imagine a sensor monitoring a factory machine. Most of the time, it produces a steady rhythm (the dominant regime). Occasionally, during a specific startup sequence or a rare operational mode, the rhythm changes significantly but is still perfectly healthy (a "rare-normal" regime).

Because most models use "average-risk" objectives, they naturally prioritize the dominant patterns. When the model encounters a rare-normal window, it sees something it hasn't learned well and assigns it a high anomaly score. This leads to a flood of false positives. The authors identify this rare-normal over-penalization as a major bottleneck for current generative TSAD methods.

Methods

The authors propose Residual-Tail-Informed Flow Matching (RT-FM), which splits the task into two distinct phases:

  1. Stage 1: VAE-based Tail Discovery
    • They train a lightweight Temporal Variational Autoencoder (VAE) on the nominal data.
  2. Instead of using the VAE for detection, they use its latent space to find "rare" windows. They calculate a latent radius score (how far a window is from the center of the latent distribution).
  3. The "Residual" Twist: Rarity in latent space can sometimes just mean "high amplitude." To avoid simply weighting loud signals, they fit a regressor to predict the latent radius from channel-wise amplitude. They then subtract this prediction to get a residual-tail score, which isolates structural rarity from simple volume changes.
  4. Stage 2: Weighted Flow Matching (FM)
    • Flow Matching is a generative technique that learns a vector field to "transport" a simple noise distribution into the complex data distribution.
  5. RT-FM trains a data-space FM model but weights the training loss. Windows identified as "rare-normal" in Stage 1 receive higher weights.
  6. This forces the FM model to pay extra attention to the underrepresented parts of the nominal distribution without "washing out" its ability to detect actual anomalies.

At inference time, the model maps test windows back to the noise distribution. If a window maps to a low-probability region of the noise (the "Gaussian tail"), it is flagged as an anomaly.

Datasets

The authors evaluated RT-FM across a massive battery of benchmarks covering both univariate and multivariate scenarios:

  • UCR: A collection of 250 univariate sequences from diverse domains.
  • Spacecraft Telemetry: MSL and SMAP (NASA data).
  • Server/IT Infrastructure: PSM and SMD.
  • Environmental/Physical: GECCO (water quality) and SWAN (space weather).

Key Insights and Ideas

  • Detachment is Key: Unlike some methods that reweight based on the detector's own loss, RT-FM uses a detached VAE for weighting. This prevents a "chasing-your-tail" effect where the model over-focuses on samples it simply hasn't converged on yet, rather than samples that are truly rare in the distribution.
  • Amplitude Residualization: One of the "aha" moments is realizing that latent "tailness" is often just a proxy for signal power. By residualizing against amplitude, the authors ensure the model learns rare shapes and motifs, not just bigger waves.
  • Flow Matching vs. Diffusion: While diffusion models are popular, Flow Matching provides a more direct, deterministic path for mapping data to noise, which the authors find highly effective for the precise scoring required in anomaly detection.

Key Results

RT-FM consistently outperformed state-of-the-art baselines (like DCDetector and Anomaly Transformer):

  • UCR Benchmark: Achieved an F1 score of 0.723, a significant jump over the previous best of 0.672 (DCDetector).
  • False Positive Reduction: On the GECCO dataset, RT-FM reduced the false positive rate at 95% recall from 0.277 to 0.134.
  • Multivariate Performance: RT-FM secured the best VUS-PR (Volume Under the Surface of Precision-Recall) and F1 scores on five out of the six multivariate datasets.
  • Ablation Success: The authors showed that using the "residual-tail" score was strictly better than using raw VAE radius or amplitude alone, proving that their specific weighting strategy is the "secret sauce."

Limitations and Future Work

  • Inference Latency: Because Flow Matching requires solving an Ordinary Differential Equation (ODE) to map data back to noise, it is computationally heavier than simple reconstruction-based models. While batching helps, real-time "streaming" applications might find it challenging without further optimization (like model distillation).
  • Training Contamination: The model assumes the training data is mostly nominal. If the training set is heavily "contaminated" with actual anomalies, the VAE might mistakenly identify those anomalies as "rare-normal" patterns and tell the FM model to learn them.
  • Future Directions: The authors suggest looking into "contamination-robust" tail discovery and exploring faster inference techniques to make RT-FM more viable for low-latency industrial edge devices.

Summary updated

Abstract

Time series anomaly detection (TSAD) models are often trained on nominal data using average-risk objectives, which emphasize dominant normal patterns. However, real time series can contain rare but valid nominal regimes that are underrepresented in the training distribution. We show that data-space flow matching can over-penalize such rare-normal windows and assign them anomaly scores comparable to those of true anomalies. To address this, we propose Residual-Tail-Informed Flow Matching (RT-FM), an unsupervised framework that uses a temporal variational autoencoder to estimate residual latent tailness and converts it into bounded, warmup-annealed weights for training a data-space flow matching model. Experiments on seven TSAD benchmarks show that RT-FM improves rare-normal coverage while preserving strong anomaly discrimination, substantially reducing false alarms on such windows and resulting in improved aggregate detection performance. The code is available at: https://github.com/trustAIoT/RT-FM_time-series-anomaly
BibTeX
@misc{saravanan2026residual,
  author = {Shyam Sundar Saravanan and Tie Luo and Sanjay Madria},
  title = {{Residual-Tail-Informed Flow Matching for Time Series Anomaly Detection}},
  year = {2026},
  eprint = {2611.20334},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.20334},
}
Figure