COMET: Codebook-based Online-adaptive Multi-scale Embedding for Time-series Anomaly Detection

Jinwoo Park, Hyeongwon Kang, Seung Hun Han, Pilsung KangNeurIPS 2026

TL;DR

Monitoring complex sensor networks for anomalies is tough because "normal" behavior spans multiple timescales, involves tangled interactions between variables, and drifts over time. COMET solves this by compressing normal multi-scale time-series patterns into a compact "dictionary" of discrete prototypes (a codebook) and safely updating that dictionary on the fly during deployment. It outperforms heavyweight Transformers on 39 out of 45 benchmark metrics using just a fraction of the parameters.

What Problem Does This Paper Address?

Imagine monitoring a water treatment plant or a spacecraft. Because anomalies are rare and expensive to label, we usually train unsupervised models on predominantly normal data and flag anything that looks unfamiliar. However, three nagging issues trip up existing methods:

  1. Tangled scales and variables: Recent models slice time series into "patches" (short windows), but often use a single fixed window size and treat each sensor independently—missing anomalies that emerge across different durations or from broken correlations between sensors.
  2. Timestep myopia: Many reconstruction models score anomalies one individual timestamp at a time. A subtle, collective deviation across a broader window can slip right by if each isolated point looks plausible enough.
  3. Concept drift at test time: Real-world systems aren't stationary; normal operating baselines drift. Adapting a model during inference (Test-Time Adaptation, or TTA) is risky because existing methods use brittle score thresholds to guess what is "normal." Guess wrong, and your model accidentally learns that an ongoing failure is the new normal.

Methods

COMET (Codebook-based Online-adaptive Multi-scale Embedding for Time-series anomaly detection) unifies three tightly coupled ideas into a surprisingly lightweight linear architecture:

Figure 1: Overall architecture of COMET. (Top-left) During training, input time series are processed via Multi-scale Patch Encoder to capture temporal contexts at different resolutions. The resulting embeddings are mapped to a Vector-Quantized Coreset, where activated codebook entries are stored in the memory bank. (Top-right) During inference, Online Codebook Adaptation selectively updates the codebook by identifying reliable normal samples through pseudo-labeling and contrastive learning. Anomaly scores are computed by combining memory distance and quantization error. (Bottom-left) Detailed illustration of vector quantization, where continuous patch embeddings are assigned to their nearest codebook entries and represented by the corresponding quantized embeddings. (Bottom- right) Detailed illustration of Online Codebook Adaptation, comprising normal filtering, contrastive learning, and index-wise coreset update. Reliable normal samples are selected based on training- activated codebook entries, and the corresponding codebook prototypes are updated to adapt to distribution shifts while reducing contamination from anomalous patterns.
  • Multi-scale Patch Encoder: Instead of one window size, COMET slices the time series at multiple patch scales. At each scale, it runs a lightweight independent linear encoder per variable (capturing unique sensor quirks) alongside a shared "core" encoder across concatenated variables (capturing cross-sensor correlations), fusing both together.
  • Vector-Quantized Coreset & Dual Scoring: Using Vector Quantization (VQ)—a standard technique for mapping continuous vectors to a finite set of discrete "codebook" entries—COMET compresses normal patch embeddings into representative prototypes. Any codebook entry activated during training enters a compact memory bank. At test time, patches are scored using two complementary signals:
  • Quantization error: How poorly the continuous embedding fits its assigned prototype.
  • Local scaling memory distance: How far that prototype sits from its neighbors in the memory bank, normalized by local neighborhood density so sparse normal regions don't trigger false alarms.
Figure 2: Comparison between global distance and local scaling distance. (Left) Global distance fails to identify normal queries in sparse regions as it relies solely on absolute distance without considering local density. (Right) Local scaling distance accounts for local density, leading to more consistent classification of queries across regions with varying density.
  • Online Codebook Adaptation (The Novel Twist): How do you adapt at test time without arbitrary thresholds? COMET checks which codebook entry a test sample hits. If that entry was activated during normal training, the sample is pseudo-labeled "normal"; if it hits a dormant, unused entry, it's flagged "abnormal." COMET then uses contrastive learning to push normal and abnormal representations apart while updating only the normal prototypes—preventing anomaly contamination.

Datasets

No new datasets were introduced. The authors evaluate COMET on five standard, diverse multivariate time-series anomaly detection benchmarks:

  • PSM (server machine metrics)
  • SWaT & WADI (water treatment and distribution cyber-physical testbeds)
  • SMAP & MSL (NASA spacecraft telemetry and rover sensor data)

Key Insights and Ideas

  • Dormant codebook entries act as threshold-free anomaly traps: Using training-time codebook activation as a binary filter for Test-Time Adaptation is remarkably clever. It sidesteps hyperparameter-sensitive score thresholding altogether.
  • You don't need massive Transformers: Because COMET relies on simple linear layers and discrete prototypes rather than heavy self-attention blocks, it achieves top-tier accuracy on PSM with just 567K parameters—roughly 1.2% the size of recent Transformer competitors like CATCH (48.6M).
  • End-to-end VQ beats post-hoc clustering: Trying to build a memory bank after training via K-Means takes ~4× longer and performs worse across the board than learning the VQ codebook jointly during training.
  • TTA shines brightest when the ground shifts: Measuring the distribution shift between train and test sets reveals a clear pattern—the bigger the drift (such as on SWaT and PSM), the larger the performance boost from Online Codebook Adaptation.

Key Results

Tested against seven baselines (including Anomaly Transformer, USAD, D3R, and CATCH) across 9 point-wise and range-based metrics on 5 datasets (45 total evaluations):

  • State-of-the-art out of the box: Even without test-time adaptation, COMET ranks #1 on 39 out of 45 metrics, excelling on rigorous range-based metrics (like Affiliation-F1 and VUS-PR) where point-adjusted baselines often collapse.
  • Consistent online gains: Turning on Online Codebook Adaptation further improves 35 out of 45 metrics over static COMET (e.g., boosting SWaT R-AUC-PR to 66.42% vs. the best baseline's 47.41%).
  • Contamination resilience: When synthetic anomalies are injected into up to 25% of the training data, COMET maintains the highest VUS-PR on four of the five datasets.

Limitations and Future Work

The authors highlight two practical caveats:

  1. Manual codebook sizing: The total number of codebook entries ($M$) is empirically tuned per dataset rather than determined automatically.
  2. Vulnerability to heavy training contamination: Because Online Codebook Adaptation trusts codebook entries activated during training, severely polluted training data can corrupt those initial activations and weaken pseudo-labeling (as seen on contaminated MSL, where COMET trails the top baseline by 5–7%). Automating codebook capacity and hardening pseudo-labeling against dirty training sets remain open avenues for future work.

Summary updated

Abstract

Multivariate time-series anomaly detection aims to identify abnormal temporal patterns in complex real-world systems. However, robust unsupervised time-series anomaly detection remains challenging because anomalies can manifest over different temporal ranges and emerge from interactions among variables, while distribution shifts can cause normal patterns to drift over time. To address these challenges, we propose Codebook-based Online-adaptive Multi-scale Embedding for Time-series anomaly detection (COMET), a unified framework with three tightly coupled components. First, Multi-scale Patch Encoder learns correlation-aware patch embeddings by combining variable-specific temporal dynamics with shared inter-variable structure across multiple patch scales. Second, Vector-Quantized Coreset quantizes these embeddings into representative normal prototypes, which are used to detect anomalies through a dual score combining quantization error and density-aware memory distance. Third, Online Codebook Adaptation leverages the same codebook structure to identify reliable normal samples from training-activated codebook entries, and then updates the prototypes through contrastive learning at inference time. Experiments on five benchmark datasets demonstrate that COMET achieves the best performance on 39 out of 45 evaluation metrics compared to seven baselines, showing robust performance across diverse evaluation protocols.
BibTeX
@inproceedings{park2026comet,
  author = {Jinwoo Park and Hyeongwon Kang and Seung Hun Han and Pilsung Kang},
  title = {{COMET: Codebook-based Online-adaptive Multi-scale Embedding for Time-series Anomaly Detection}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=gEg9NAe7OM},
}
Figure