Adapting Large Language Models to Log Analysis with Interpretable Domain Knowledge

Yuhe Ji, Yilun Liu, Feiyu Yao, Minggui He, Shimin Tao, Xiaofeng Zhao, Chang Su, Xinhua Yang, Weibin Meng, Yuming Xie, Boxing Chen, Shenglin Zhang, Yongqian Sun

Abstract

System logs are essential for debugging and security, but their cryptic nature makes them difficult for general-purpose Large Language Models (LLMs) to interpret. We introduce SuperLog, a model specifically adapted for log analysis. Unlike previous approaches that train on raw logs, SuperLog utilizes interpretable domain knowledge via a new dataset, NLPLog, containing over 250,000 natural language Q&A pairs. Our results show that SuperLog outperforms state-of-the-art models by an average of 12% across various tasks while maintaining high interpretability for human engineers.

Introduction

Modern software infrastructure relies on system logs to record operational events. However, these logs are often a "black box"—a messy mixture of timestamps, IP addresses, and hex codes that do not follow standard natural language patterns. While LLMs like LLaMA-2 excel at general reasoning, they struggle with the unique token distribution of logs. Previous attempts to bridge this gap by training models directly on raw logs often lead to "catastrophic forgetting," where the model loses its general reasoning capabilities and becomes a "black box" itself, unable to explain its findings.

Methodology: The SuperLog Framework

To address these challenges, we developed a domain adaptation strategy that prioritizes interpretability. The core idea is to teach the model the logic of log analysis using natural language descriptions rather than just raw data.

Overview of the SuperLog training framework compared to standard adaptation methods.

The training process involves two main stages:

  1. Continual Pre-Training (CPT): We perform CPT on a base LLaMA-2-7B model using the NLPLog dataset. This stage infuses the model with domain-specific knowledge across five dimensions: Grok pattern parsing, log event insights, root cause analysis, component correlation, and failure forecasting.
  2. Instruction Tuning: Following CPT, the model undergoes general instruction tuning to ensure it remains conversational and capable of following complex human prompts.

The NLPLog Dataset

The effectiveness of SuperLog stems from NLPLog, a meticulously curated dataset designed to translate technical log patterns into natural language. It consists of over 250,000 Q&A pairs spanning 14 diverse domains, including Windows, Linux, and HDFS.

Statistics of the NLPLog dataset across various system domains.

By using natural language to describe logs, we minimize the "distribution shift" that typically occurs when forcing a language model to process machine code. This approach allows the model to learn the underlying principles of system behavior, facilitating better generalization to unseen environments.

Key Results and Evaluation

SuperLog was evaluated against several benchmarks, including LogHub_2k for parsing and BGL/Spirit for anomaly detection. Key findings include:

  • Superior Accuracy: SuperLog achieved a 12.01% average accuracy improvement over the next best model across all evaluated tasks.
  • Enhanced Parsing: In log parsing tasks, the model showed an 18.3% improvement in RandIndex and a 13.3% boost in F1-score.
  • Zero-Shot Generalization: On unseen domains like Apache and OpenStack, SuperLog improved ROUGE scores by 22.4%, demonstrating its ability to apply learned logic to unfamiliar log structures.
  • Human-Centric Interpretability: In evaluations by human engineers, SuperLog's explanations were rated significantly higher for usefulness and readability compared to general-purpose models like LLaMA-3.1.

Conclusion and Future Work

SuperLog demonstrates that training LLMs on interpretable domain knowledge is more effective for log analysis than training on raw data. While the model significantly advances the state-of-the-art, challenges such as potential hallucinations in high-stakes environments remain. Future research will focus on expanding the diversity of training domains and developing more robust metrics to verify the model's deep understanding of system logic.

Summary updated

BibTeX
@inproceedings{ji2024adapting,
  author = {Yuhe Ji and Yilun Liu and Feiyu Yao and Minggui He and Shimin Tao and Xiaofeng Zhao and Chang Su and Xinhua Yang and Weibin Meng and Yuming Xie and Boxing Chen and Shenglin Zhang and Yongqian Sun},
  title = {{Adapting Large Language Models to Log Analysis with Interpretable Domain Knowledge}},
  booktitle = {ACM International Conference on Information and Knowledge Management},
  year = {2024},
}
Figure