Abstract
Anomaly detection (AD) is a critical task across numerous domains, yet the technical barrier to implementing state-of-the-art pipelines remains high for non-experts. We present AD-AGENT, an LLM-powered multi-agent framework that translates natural language instructions into executable AD workflows. By orchestrating specialized agents for data processing, library selection, and iterative debugging, the system enables non-experts to deploy sophisticated AD models across tabular, graph, and time-series data with high reliability and minimal cost.
Introduction
The proliferation of open-source anomaly detection libraries such as PyOD, PyGOD, and TSLib has provided researchers with powerful tools. However, these libraries often feature incompatible APIs and require deep domain knowledge to select appropriate models and configure data pipelines. For domain experts in fields like medicine or finance, this "learning overhead" often prevents the adoption of advanced AD techniques. AD-AGENT addresses this challenge by providing an end-to-end automated platform that handles the complexities of code generation and validation through a natural language interface.
The AD-AGENT Framework
AD-AGENT utilizes a modular architecture where distinct agents, powered by Large Language Models (LLMs), collaborate to fulfill a user's request. The workflow is decomposed into several functional roles:
- Processor & Selector: The Processor identifies data attributes and user intent, while the Selector recommends the optimal library and model for the specific task.
- Info Miner: This agent performs targeted web searches to retrieve documentation and code examples, ensuring the system stays up-to-date with library changes.
- Code Generator & Reviewer: These agents operate in a feedback loop. The Generator produces the initial script, which the Reviewer then validates against synthetic data. If errors are detected, the loop continues until the code is verified as runnable.
- Evaluator & Optimizer: These optional components summarize results and perform automated hyperparameter tuning to maximize model performance.
A key innovation is the dual-memory system. Short-term memory tracks session-specific context, while long-term memory serves as a persistent cache for documentation. This architecture significantly reduces latency and API costs by avoiding redundant external searches.
Experimental Evaluation
The framework was benchmarked against three major AD categories:
- Tabular Data (PyOD): Tested on 17 datasets from ADBench (e.g., cardio, mnist).
- Graph Data (PyGOD): Evaluated on 5 datasets from BOND (e.g., enron, reddit).
- Time-Series Data (TSLib): Tested on 5 standard datasets (e.g., MSL, SMAP).
Key Results
AD-AGENT demonstrated exceptional reliability, achieving a 100% success rate in generating executable code for the PyOD library and over 90% for PyGOD and TSLib. The efficiency of the system is notable; a complete, verified pipeline is typically generated in 20 to 125 seconds, with an average token cost of approximately $0.015.
Furthermore, the automated Optimizer agent significantly enhanced detection quality. In one instance using the LUNAR model, automated hyperparameter tuning improved the Area Under the Receiver Operating Characteristic curve (AUROC) from 0.52 to 0.79, demonstrating that the system can outperform baseline configurations without human intervention.
Discussion and Insights
The success of AD-AGENT highlights the efficacy of the "Reviewer" loop. Iterative self-correction allows the system to resolve common programming pitfalls—such as deprecated parameters or naming mismatches—independently. Additionally, the study found that LLMs (specifically o4-mini) are highly capable model selectors, with their recommendations closely matching the performance of the theoretical "best" models across various datasets.
Limitations
Despite its strengths, AD-AGENT remains susceptible to LLM hallucinations and breaking changes in external libraries not yet reflected in its memory. Complex internal data constraints can still occasionally lead to runtime errors that the Reviewer loop may not fully resolve.
Conclusion
AD-AGENT represents a significant step toward democratizing advanced anomaly detection. By abstracting the "plumbing" of data science through a multi-agent LLM architecture, it enables non-technical users to deploy robust, optimized AD pipelines. Future work will focus on expanding support to image and text modalities and enhancing the framework's conversational capabilities for iterative pipeline refinement.
Summary updated