Introduction
Time Series Anomaly Detection (TSAD) is a critical task in domains ranging from industrial monitoring and health tracking to network security. Despite its importance, the field faces two significant challenges: data scarcity and the lack of universal pre-trained models. Unlike Computer Vision or Natural Language Processing, where massive datasets like ImageNet or Common Crawl enable the creation of foundational models, time series data is often fragmented across domains, making it difficult to develop models that generalize well.
To address these hurdles, the authors propose AnomalyLLM, a novel framework that leverages the generalized representation power of Large Language Models (LLMs) to guide anomaly detection. By employing a knowledge distillation approach, AnomalyLLM identifies anomalies based on the feature discrepancy between a fine-tuned LLM "teacher" and a specialized "student" network.
Methodology
The core of AnomalyLLM is a knowledge distillation framework designed to capture the "normal" patterns of time series data while remaining sensitive to deviations.
The Teacher-Student Framework
The architecture consists of two primary components:
- Teacher Network (LLM-based): The researchers utilized a pre-trained GPT-2 model as the teacher. To adapt the LLM to time series data, the core attention and feed-forward layers remain frozen to preserve general sequence knowledge. However, the positional embeddings and layer normalization are fine-tuned, allowing the model to project time series signals into a rich, high-dimensional feature space.
- Student Network (Prototype-based): The student is a more compact Transformer-based network. To prevent the student from over-fitting and simply mimicking the teacher's ability to represent anomalies, the authors introduced Prototypical Signals. These are trainable segments representing "typical" patterns that guide the student to focus on historical normality.
Detection Logic and Training
During training, the student learns to minimize the discrepancy between its output and the teacher's output on normal data. At inference time, any segment that produces a high "discrepancy score"—where the student's prediction significantly differs from the teacher's representation—is flagged as an anomaly.
To enhance robustness, the authors employed:
- Synthetic Anomalies: Data augmentation techniques (jittering, scaling, warping) create "fake" anomalies, and the model is trained to maximize the discrepancy on these samples.
- Contrastive Loss: A negative-sample-free contrastive loss ensures that the teacher's representations are robust to noise and maintain consistency across augmented views of the same data.
Experimental Setup
AnomalyLLM was evaluated across a comprehensive suite of 15 real-world datasets. This includes the UCR Anomaly Archive, which contains 250 univariate signals from 9 different domains (e.g., NASA telemetry, gait analysis, arterial blood pressure). Additionally, the model was tested on six multivariate benchmarks, including the Server Machine Dataset (SMD) and Mars Science Laboratory (MSL).
Results and Discussion
The experimental results demonstrate that AnomalyLLM sets a new state-of-the-art (SOTA) in time series anomaly detection.
Performance Benchmarks
On the UCR dataset, AnomalyLLM achieved a significant 14.5% accuracy improvement over previous methods. It also outperformed specialized multivariate models like DCdetector and AnomalyTrans on complex datasets such as WaQ and SWAN.
Zero-Shot and Few-Shot Capabilities
One of the most striking findings is the model's robustness in data-scarce scenarios. In zero-shot settings—where the model is tested on a target scene it has never seen during training—AnomalyLLM maintained an F1-score of 0.650, vastly outperforming competing models like TSTCC, which dropped to 0.139. This suggests that the "pre-baked" knowledge within the LLM teacher provides a powerful foundation for cross-domain generalization.
Conclusion
AnomalyLLM demonstrates that LLMs, despite being trained on text, possess inherent sequence-modeling capabilities that can be effectively transferred to the time series domain. By using a discrepancy-based distillation approach and prototypical anchors, the framework overcomes the limitations of traditional reconstruction-based methods. While the computational overhead of using an LLM teacher remains a challenge for real-time edge deployment, the significant gains in accuracy and few-shot robustness mark a major step forward for the field.
Summary updated