AdaptiveLog: An Adaptive Log Analysis Framework with the Collaboration of Large and Small Language Model

Lipeng Ma, Weidong Yang, Yixuan Li, Ben Fei, Mingjie Zhou, Shuhao Li, Sihang Jiang, Bo Xu, Yanghua Xiao

TL;DR

AdaptiveLog is a hybrid log analysis framework that combines the cost-efficiency of Small Language Models (SLMs) with the advanced reasoning power of Large Language Models (LLMs). By using a Bayesian uncertainty estimation strategy, it routes simple logs to a fast, fine-tuned SLM and reserves the expensive LLM only for complex, uncertain cases. This collaborative approach achieves state-of-the-art accuracy across multiple log analysis tasks while slashing LLM inference costs by over 70%.

What Problem Does This Paper Address?

Automated log analysis—such as anomaly detection, root cause analysis, and failure prediction—is vital for maintaining the reliability of modern cloud and network infrastructure. Recently, language models have split this field into two dominant paradigms:

  1. Small Language Models (SLMs): Models like BERT are fine-tuned on task-specific datasets. They are fast and cost-effective but struggle with rare, complex, or out-of-distribution anomaly patterns.
  2. Large Language Models (LLMs): Models like ChatGPT use in-context learning to reason through logs without parameter updates. They are incredibly powerful but suffer from high latency and prohibitive API costs when processing millions of log lines per hour.

The core challenge is finding a balance: how can we leverage the deep reasoning capabilities of LLMs for complex system failures without breaking the bank on standard, repetitive log messages?

The trade-offs between SLMs, LLMs, and AdaptiveLog

Methods

The authors introduce AdaptiveLog, a framework that orchestrates a dynamic collaboration between an SLM and an LLM using three main steps:

  1. Inference with SLM: Every incoming log is first processed by a task-tuned SLM (e.g., BERT) to generate an initial prediction.
  2. Model Adaptive Selection via Uncertainty Estimation: To decide if the LLM needs to step in, the framework estimates the SLM's prediction uncertainty using Bayesian inference (via Monte Carlo Dropout). If the SLM's uncertainty probability exceeds its certainty probability, the log is classified as a "hard case" and escalated to the LLM. Otherwise, the SLM's cheap prediction is used directly.
  3. Error-Case Reasoning Enhancement (ECR): When the LLM is invoked, standard few-shot prompting isn't enough for these hard cases. AdaptiveLog uses a pre-computed "mistake memory bank" containing historical samples where the SLM failed. The framework retrieves the most similar past error cases and feeds them to the LLM, along with explanations of why those cases are deceptive and what pitfalls to avoid.
The detailed architecture of the AdaptiveLog framework

Datasets

The framework was evaluated across six distinct downstream tasks spanning two main domains:

  • Software System Logs:
    • BGL and ThunderBird (from the Loghub benchmark) for binary Anomaly Detection.
  • OpenStack for a 16-class Failure Identification task.
  • Network Device Logs: Real-world documentation logs from Cisco and Huawei routers and switches, covering four tasks: Module Classification, Level Prediction, Log-Description Semantic Matching, and Log-Possible Cause Ranking.

Key Insights and Ideas

  • Uncertainty is a Highly Reliable Router: The authors discovered that the SLM's uncertainty distribution is strongly bimodal. For correct predictions, uncertainty scores cluster tightly between 0.0 and 0.4. For incorrect predictions (hard cases), they cluster between 0.8 and 1.0. This clear separation makes Bayesian uncertainty an excellent proxy for routing.
  • Negative Examples Outperform Positive Ones: Traditional in-context learning provides LLMs with successful examples to mimic. ECR flips this by providing negative examples (the SLM's mistakes) paired with explicit reasoning on why they are tricky. This prevents the LLM from falling into the same cognitive traps as the smaller model.
  • The "Weaker SLM" Self-Correction: In low-resource scenarios (e.g., when the SLM is trained on only 10% of data), the framework automatically compensates by routing more logs (~32-40%) to the LLM, maintaining high overall system accuracy despite a weaker base model.

Key Results

  • Massive Cost Savings: On average across all six tasks, AdaptiveLog only needed to invoke the LLM for 27% of the datasets. This translates to a 73% cost reduction compared to a pure LLM approach.
  • Superior Accuracy: AdaptiveLog (using ECR) consistently outperformed pure SLM baselines (BERT, KnowLog) and pure ChatGPT. For instance, on the ThunderBird anomaly detection dataset, AdaptiveLog achieved an F1-score of 94.99%, outperforming pure ChatGPT (91.26%) and pure BERT (92.84%).
  • Reduced Latency: By filtering out simple cases, AdaptiveLog saved an average of 66.27% in runtime execution compared to full-sample LLM inference.

Limitations and Future Work

While highly effective, AdaptiveLog relies on a task-specific validation set during its preparation stage to harvest the SLM's errors and build the mistake memory bank. In a completely cold-start or zero-shot production environment where no validation data exists, initializing this database would be difficult. Additionally, appending detailed reasoning and potential pitfalls for multiple retrieved cases increases the token length of the LLM prompts, slightly increasing the cost per LLM invocation, though this is heavily offset by the massive reduction in total invocations.

Future work includes exploring more advanced base SLMs to lower the escalation rate even further and adapting the framework for real-time streaming log pipelines.

Summary updated

BibTeX
@article{ma2026adaptivelog,
  author = {Lipeng Ma and Weidong Yang and Yixuan Li and Ben Fei and Mingjie Zhou and Shuhao Li and Sihang Jiang and Bo Xu and Yanghua Xiao},
  title = {{AdaptiveLog: An Adaptive Log Analysis Framework with the Collaboration of Large and Small Language Model}},
  journal = {ACM Trans. Softw. Eng. Methodol.},
  year = {2026},
  doi = {10.1145/3749840},
}
Figure