Text-ADBench: Text Anomaly Detection Benchmark based on LLMs Embedding

Feng Xiao, Jicong FanarXiv 2025 · DOI

Introduction

Anomaly detection (AD)—the process of identifying data points that deviate significantly from the norm—is a cornerstone of modern digital safety, powering everything from fraud detection to content moderation. While AD techniques for structured data are well-established, applying them to natural language remains a formidable challenge. Textual data is high-dimensional and semantically complex, requiring sophisticated representations to distinguish between "normal" variation and true anomalies.

Despite the rapid advancement of Large Language Models (LLMs), the field has lacked a standardized, large-scale benchmark to evaluate how these modern embeddings impact unsupervised text AD. Previous studies were often limited in scope, focusing on older models like BERT or a narrow set of algorithms. Text-ADBench addresses this gap by providing a rigorous framework that pairs 33 different LLM embeddings with 12 detection algorithms across 14 diverse tasks.

Comparison of Text-ADBench with existing benchmarks, highlighting its extensive coverage of LLMs, embeddings, and performance analysis capabilities.

The Text-ADBench Framework

The core of Text-ADBench is a systematic two-stage pipeline designed to isolate the effects of feature extraction and anomaly detection algorithms.

  1. Feature Extraction: The benchmark leverages a diverse suite of embedding models. This includes "early" language models (GloVe, BERT), open-source LLMs (LLaMA-2, LLaMA-3, Mistral), and state-of-the-art proprietary models from OpenAI. A critical component of this stage is the pooling strategy. For decoder-only LLMs, the authors compare "Mean" pooling, "Weighted Mean," and "EOS" (using the embedding of the final End-Of-Sequence token) to determine the most effective way to represent a full document as a single vector.
  2. Anomaly Detection: These generated embeddings are then processed by 12 different algorithms. The selection spans three categories: shallow/classical methods (e.g., OCSVM, Isolation Forest, KNN), deep learning methods (e.g., AutoEncoders, Deep SVDD), and specialized text AD methods (CVDD, DATE).
The two-stage pipeline of Text-ADBench: raw text from the AD Corpus is transformed into embeddings by LLMs, which are then processed by various AD algorithms for training and inference.

Datasets and Experimental Setup

To ensure robustness, the benchmark utilizes 14 specialized AD tasks derived from 8 real-world text classification datasets. These cover a wide range of domains, including news (20Newsgroups, Reuters21578), sentiment analysis (IMDB, SST2), communication (SMS-Spam, Enron emails), and academic abstracts (WOS, DBpedia). By designating specific classes as "normal" and others as "anomalous," the authors create a challenging environment for unsupervised detection.

Key Insights: The Power of LLM Embeddings

The study yields several surprising insights that challenge conventional wisdom in the field:

  • Embeddings are the Engine: The quality of the LLM embedding is the single most influential factor in detection performance. High-quality embeddings from models like LLaMA-3 or OpenAI's text-embedding-3-large significantly elevate the performance of any downstream algorithm.
  • The "Shallow" Paradox: One of the most striking findings is that complex deep learning-based anomaly detectors (like AutoEncoders) showed no inherent advantage over conventional shallow algorithms when using LLM embeddings. In fact, K-Nearest Neighbors (KNN) emerged as the most consistent top performer. This suggests that modern LLMs organize the input space so effectively that complex non-linear detection heads become redundant.
  • EOS is King: For modern decoder-only LLMs, the "EOS" pooling strategy generally outperforms simple averaging, capturing the semantic essence of the document more effectively for outlier detection.

Performance Predictability and Low-Rank Structure

Beyond individual model rankings, the authors discovered an underlying mathematical order in the results. By applying Singular Value Decomposition (SVD) to the performance matrix (Models × Datasets), they demonstrated that the results are "low-rank." This means a few latent factors explain the majority of the performance variance.

This discovery has significant practical implications: performance is highly predictable. Using Matrix Completion techniques, the authors could predict missing performance values with a Mean Absolute Percentage Error (MAPE) often below 0.1. In a production environment, this allows researchers to "shortcut" the expensive process of testing every algorithm on every dataset, reliably predicting the best configuration from a small subset of measurements.

Conclusion

Text-ADBench marks a significant step forward in standardizing text anomaly detection. By demonstrating that "less is more"—where high-quality embeddings paired with simple classical algorithms often yield the best results—the paper provides a clear roadmap for practitioners. The open-sourcing of the toolkit and pre-computed embeddings further ensures that the community can build upon these findings to tackle increasingly complex real-world anomalies.

Summary updated

BibTeX
@misc{xiao2025text,
  author = {Feng Xiao and Jicong Fan},
  title = {{Text-ADBench: Text Anomaly Detection Benchmark based on LLMs Embedding}},
  year = {2025},
  eprint = {2507.12295},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.12295},
}
Figure