Abstract:
Anomaly detection for time series holds practical value in diverse fields such as financial risk control and industrial fault diagnosis, where the core challenge lies in constructing a representation space that effectively distinguishes between normal and anomalous patterns. However, the inherent characteristics of temporal data, coupled with the extreme scarcity of labeled anomalies, make it highly difficult to learn a representative mapping function with strong discriminative power, often leading to limited generalization capabilities. Meanwhile, contrastive representation learning constructs a discriminative feature space that clearly differentiates between instances, offering a more natural and promising solution for temporal anomaly detection. To address these challenges, we propose a dual anomaly-aware transformer (DAT) model. By incorporating anomaly injection and anomaly awareness mechanisms, DAT is specifically enabled to capture the complex features of potential anomalous samples during the training phase. Additionally, a contextual contrastive loss function is adopted to guide a dual-branch structure for extracting more intrinsic and discriminative semantic features between normal and anomalous samples. Comprehensive experiments conducted on five public datasets demonstrate the superiority of DAT over 21 baseline models. The results show that DAT not only achieves competitive performance across all benchmark datasets but also achieves state-of-the-art (SOTA) performance on the MSL and PSM datasets.