[论文解读] LogLLM: Log-based Anomaly Detection Using Large Language Models
LogLLM 是一种新颖的基于日志的异常检测框架,利用 BERT 提取语义向量,使用 Llama 进行序列分类,并通过投影器对齐其表示空间。通过三阶段训练流程进行训练,在四个公开数据集上优于最先进方法,即使在日志不稳定和数据不平衡条件下也能实现稳健的异常检测。
Software systems often record important runtime information in logs to help with troubleshooting. Log-based anomaly detection has become a key research area that aims to identify system issues through log data, ultimately enhancing the reliability of software systems. Traditional deep learning methods often struggle to capture the semantic information embedded in log data, which is typically organized in natural language. In this paper, we propose LogLLM, a log-based anomaly detection framework that leverages large language models (LLMs). LogLLM employs BERT for extracting semantic vectors from log messages, while utilizing Llama, a transformer decoder-based model, for classifying log sequences. Additionally, we introduce a projector to align the vector representation spaces of BERT and Llama, ensuring a cohesive understanding of log semantics. Unlike conventional methods that require log parsers to extract templates, LogLLM preprocesses log messages with regular expressions, streamlining the entire process. Our framework is trained through a novel three-stage procedure designed to enhance performance and adaptability. Experimental results across four public datasets demonstrate that LogLLM outperforms state-of-the-art methods. Even when handling unstable logs, it effectively captures the semantic meaning of log messages and detects anomalies accurately.
研究动机与目标
- 解决传统深度学习方法在捕捉自然语言日志语义含义方面的局限性。
- 克服基于大语言模型的异常检测中的挑战,如语义理解能力差、大语言模型利用不充分,以及长输入序列导致的内存溢出问题。
- 通过使用正则表达式进行日志预处理,而非依赖日志解析器,消除对日志解析器的依赖,简化处理流程。
- 通过一种新颖的三阶段训练流程,提升日志异常检测的性能与适应性。
- 通过研究少数类过采样方法并引入超参数 $β$,确保模型对数据不平衡的鲁棒性。
提出的方法
- 使用 BERT(一种基于 Transformer 编码器的模型)从单个日志消息中提取密集的语义向量。
- 使用 Llama(一种基于 Transformer 解码器的模型)基于其语义表示对整个日志序列进行分类。
- 引入一个可学习的投影器,对齐 BERT 和 Llama 的向量表示空间,确保端到端流程中的语义一致性。
- 使用正则表达式而非日志解析器对日志消息进行预处理以提取模板,从而简化工作流。
- 通过三阶段训练流程训练模型:(1) 预训练 BERT 和投影器,(2) 冻结 Llama 的情况下微调 BERT 和投影器,(3) 联合微调整个模型。
- 应用少数类过采样方法,引入超参数 $β$,以缓解训练数据中的类别不平衡问题。
实验结果
研究问题
- RQ1结合 BERT 和 Llama 并引入表示空间对齐的框架,是否能优于现有的基于日志的异常检测方法?
- RQ2三阶段训练流程是否能提升日志异常检测中模型的性能与适应性?
- RQ3在日志不稳定、模板频繁变更的条件下,LogLLM 检测异常的有效性如何?
- RQ4少数类过采样($β$)对模型性能和训练效率的影响是什么?
- RQ5在数据不平衡和长输入序列条件下,该框架是否能保持高性能且避免内存溢出?
主要发现
- LogLLM 在四个公开数据集上均达到 SOTA 性能,优于现有方法的异常检测效果。
- 消融实验证实,三阶段训练流程显著提升性能,当省略阶段 1 和阶段 2 时,F1 分数分别下降 2.5% 和 3.2%。
- 当 $β$ 取值在 30% 至 50% 之间时,少数类过采样可实现稳定性能,F1 分数变化极小(≤0.07),表明对 $β$ 的敏感度较低。
- 当 Thunderbird 数据集中异常样本仅占 1.05% 时,若不进行过采样,LogLLM 的 F1 分数为 0,凸显数据平衡的必要性。
- 随着 $β$ 增大,训练时间增加,但 $β$ 在 30% 至 50% 范围内时,性能稳定且开销可接受。
- 即使在日志不稳定、模板持续演化的条件下,LogLLM 仍能有效捕捉语义信息,并以高精度检测异常。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。