Abstract: Two-step approaches combining pre-trained large language model embeddings and anomaly detectors demonstrate strong performance in text anomaly detection by leveraging rich semantic representations. However, high-dimensional dense embeddings extracted by large language models pose challenges due to substantial memory requirements and high computation time. To address this challenge, we introduce the Simplified Isolation Kernel (SIK), which maps high-dimensional dense embeddings to lower-dimensional sparse representations while preserving crucial anomaly characteristics. SIK has linear time complexity and significantly reduces space complexity through its innovative boundary-focused feature mapping. Experiments across 7 datasets demonstrate that SIK achieves better detection performance than 11 state-of-the-art (SOTA) anomaly detection algorithms while maintaining computational efficiency and low memory cost. All code and demonstrations are available at https://github.com/charles-cao/SIK.
Introduction
Text Anomaly Detection (TAD) is essential for identifying spam, fraud, and security threats. Currently, the most effective approach is a "two-step" process: first, use a pre-trained Large Language Model (LLM) like BERT or OpenAI’s embeddings to turn text into dense vectors, and then apply an anomaly detection algorithm.
However, LLM embeddings are high-dimensional (often 768 to 3072+ dimensions), leading to the "curse of dimensionality." Traditional algorithms like the Isolation Kernel (IK) struggle here because they create feature maps even higher-dimensional than the input, resulting in massive memory consumption and slow computation. The Simplified Isolation Kernel (SIK) aims to bridge the gap between the rich semantic power of LLMs and the need for fast, scalable anomaly detection.
Methodology: Simplified Isolation Kernel (SIK)
The core innovation of SIK is a "boundary-focused" feature mapping strategy that prioritizes identifying points outside normal regions over modeling internal similarities.
The SIK process involves:
- Space Partitioning: SIK uses a hypersphere-based partitioning strategy where radii are set based on the distance to the nearest neighbor, allowing the spheres to adapt to local data density.
- Simplified Mapping: While the standard IK tracks which specific hypersphere a data point falls into (size $t \times \psi$), SIK only records if a point falls outside all hyperspheres in a partitioning (size $t$). This effectively compresses the feature space from $O(t\psi)$ to $O(t)$.
- Anomaly Scoring: Scores are calculated by measuring how often a point falls outside the "normal" boundaries across multiple random partitionings.
Experimental Evaluation
We evaluated SIK using the NLP-ADBench benchmark across seven diverse datasets, including spam detection (EmailSpam, SMSSpam), topic outliers (BBCNews, AGNews, N24News), and sentiment anomalies (MovieReview, YelpReview).
Key Results
- Superior Performance: SIK outperformed 11 state-of-the-art algorithms, including iForest and DeepSVDD. On the EmailSpam dataset using OpenAI embeddings, SIK achieved a top AUROC of 0.9729.
- Efficiency Gains: SIK completed training 14 times faster than the original IK on the SMS_Spam dataset.
- Memory Reduction: SIK required only 0.5 MB of memory for training on SMS_Spam, compared to 1235.2 MB for IK—a reduction of over 99.9%.
- Robustness: SIK proved more effective than "end-to-end" neural detectors like CVDD, which often struggle to generalize across different text domains.
Conclusion
SIK offers a highly efficient and effective solution for text anomaly detection by leveraging LLM embeddings while overcoming their high-dimensional overhead. By focusing on boundary detection rather than internal data relationships, SIK achieves state-of-the-art performance with minimal computational cost. Future work will explore its sensitivity to training data contamination and performance on subtle semantic anomalies.
Summary updated