LLM meets ML: Data-efficient Anomaly Detection on Unstable Logs
Fatemeh Hadadi, Qinghua Xu, Domenico Bianculli, Lionel Briand
TL;DR
FlexLog targets anomaly detection on unstable logs (ULAD) by fusing traditional ML detectors with a fine-tuned open/closed-source LLM in an ensemble framework. It introduces cache-empowered inference and retrieval-augmented prompting to adapt to log evolution while using limited labeled data. Across four ULAD datasets (ADFA-U, LOGEVOL-U, SynHDFS-U, SYNEVOL-U), FlexLog delivers state-of-the-art F1 scores with substantial data-efficiency gains (about 63–78% reduction in labeling) and maintains practical latency (under 1 second per log sequence) alongside modest memory overhead. Ablation studies show the cache, RAG, and ensemble components each contribute to performance, with Mistral emerging as a cost-effective yet competitive LLM choice. The work demonstrates a scalable, data-efficient pathway to robust log-based anomaly detection in realistic, evolving software environments, while outlining future enhancements such as more powerful open LLMs and smarter ensemble strategies.
Abstract
Most log-based anomaly detectors assume logs are stable, though logs are often unstable due to software or environmental changes. Anomaly detection on unstable logs (ULAD) is therefore a more realistic, yet under-investigated challenge. Current approaches predominantly employ machine learning (ML) models, which often require extensive labeled data for training. To mitigate data insufficiency, we propose FlexLog, a novel hybrid approach for ULAD that combines ML models -- decision tree, k-nearest neighbors, and a feedforward neural network -- with a Large Language Model (Mistral) through ensemble learning. FlexLog also incorporates a cache and retrieval-augmented generation (RAG) to further enhance efficiency and effectiveness. To evaluate FlexLog, we configured four datasets for \task, namely ADFA-U, LOGEVOL-U, SynHDFS-U, and SYNEVOL-U. FlexLog outperforms all baselines by at least 1.2 percentage points (pp) in F1 score while using much less labeled data (62.87 pp reduction). When trained on the same amount of data as the baselines, FlexLog achieves up to a 13 pp increase in F1 score on ADFA-U across varying training dataset sizes. Additionally, FlexLog maintains inference time under one second per log sequence, making it suitable for most applications, except latency-sensitive systems. Further analysis reveals the positive impact of FlexLog's key components: cache, RAG and ensemble learning.
