AnomalyBERT: Self-Supervised Transformer for Time Series Anomaly Detection using Data Degradation Scheme

Yungi Jeong, Eunseok Yang, Jung Hyun Ryu, Imseong Park, Myungjoo KangarXiv 2023

Abstract

Mechanical defects in real-world scenarios affect observation values and cause abnormalities in multivariate time series, such as sensor readings or network traffic. To effectively detect these abnormalities, it is crucial to understand both the temporal context and the interrelations between variables. Anomaly detection for unlabeled time series data remains a challenging problem. We address this by proposing AnomalyBERT, a self-supervised model trained using a novel data degradation scheme. We define four types of synthetic outliers and replace portions of input data with these outliers during training. Inspired by the self-attention mechanism, AnomalyBERT utilizes a Transformer-based architecture to recognize temporal contexts and detect unnatural sequences efficiently. Our model converts multivariate data points into temporal representations with relative position bias and yields anomaly scores from these representations. AnomalyBERT demonstrates superior capability in detecting anomalies in complex time series, surpassing previous state-of-the-art methods on five real-world benchmarks.

Introduction

Detecting anomalies in multivariate time series—such as sensor data from power plants or network traffic—is critical for preventing system failures. However, obtaining expert-labeled anomaly data is notoriously difficult and expensive. Most existing methods are unsupervised but often struggle to capture complex temporal contexts and intricate relationships between multiple variables simultaneously. The challenge lies in creating a model that can learn the characteristics of "normal" data well enough to identify "abnormal" patterns without requiring human-labeled examples during training.

Methodology

AnomalyBERT is a Transformer-based architecture inspired by the BERT model. Its core innovation is a data degradation scheme used for self-supervised training. Instead of masking tokens, AnomalyBERT "degrades" random segments of an input time series window using four types of synthetic outliers: soft replacement, uniform replacement, length adjustment, and peak noise. The model is then trained to classify every point in the window as either "normal" or "degraded."

Overview of the AnomalyBERT framework, showing the data degradation process and the Transformer-based architecture.

To better handle temporal data, the standard positional encodings are replaced with 1D relative position bias. This allows the self-attention mechanism to focus on the relative distance between data points rather than their absolute position in time, which is crucial for understanding local temporal contexts in time series data.

Experiments and Results

The model was evaluated on five widely-used real-world benchmark datasets: SWaT (Secure Water Treatment), WADI (Water Distribution Testbed), MSL (Mars Science Laboratory), SMAP (Soil Moisture Active Passive), and SMD (Server Machine Dataset).

AnomalyBERT outperformed previous state-of-the-art methods (such as GDN, USAD, and OmniAnomaly) across all benchmarks. For instance, on the SWaT dataset, it achieved an F1-score of 0.854, surpassing the previous best of 0.808. On SMAP, it reached an F1-score of 0.457, nearly doubling the performance of several baseline models.

Qualitative results showing AnomalyBERT's predicted scores and latent feature separation on the SMAP and SMD datasets.

Key Insights

  • Self-Supervision via Corruption: By learning to identify specific types of artificial corruption, the model naturally learns the underlying structure of healthy data.
  • The Power of Soft Replacement: Ablation studies revealed that "soft replacement" is the most versatile degradation type, as it can mimic various real-world outlier patterns like trend changes and contextual anomalies.
  • Latent Space Separation: Visualization using t-SNE shows that AnomalyBERT effectively clusters normal and abnormal points into distinct regions in its internal representation, even without explicit labels during training.

Conclusion

AnomalyBERT demonstrates that a self-supervised approach using a data degradation scheme can effectively learn to detect anomalies in complex multivariate time series. While the degradation scheme is highly effective, future work could involve more sophisticated, data-driven ways to mix and match degradation types to better mimic specific industrial failure modes.

Summary updated

BibTeX
@misc{jeong2023anomalybert,
  author = {Yungi Jeong and Eunseok Yang and Jung Hyun Ryu and Imseong Park and Myungjoo Kang},
  title = {{AnomalyBERT: Self-Supervised Transformer for Time Series Anomaly Detection using Data Degradation Scheme}},
  year = {2023},
  eprint = {2305.04468},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.04468},
}
Figure