[论文解读] LAnoBERT: System Log Anomaly Detection based on BERT Masked Language Model
LAnoBERT 提出了一种无需解析器的、无监督的系统日志异常检测方法,利用 BERT 的掩码语言建模(MLM)学习正常日志模式,而无需依赖日志解析器。该方法在 HDFS、BGL 和 Thunderbird 数据集上实现了最先进性能,优于无监督模型,并与有监督基准相当,同时支持高效推理,适用于实际部署。
The system log generated in a computer system refers to large-scale data that are collected simultaneously and used as the basic data for determining errors, intrusion and abnormal behaviors. The aim of system log anomaly detection is to promptly identify anomalies while minimizing human intervention, which is a critical problem in the industry. Previous studies performed anomaly detection through algorithms after converting various forms of log data into a standardized template using a parser. Particularly, a template corresponding to a specific event should be defined in advance for all the log data using which the information within the log key may get lost. In this study, we propose LAnoBERT, a parser free system log anomaly detection method that uses the BERT model, exhibiting excellent natural language processing performance. The proposed method, LAnoBERT, learns the model through masked language modeling, which is a BERT-based pre-training method, and proceeds with unsupervised learning-based anomaly detection using the masked language modeling loss function per log key during the test process. In addition, we also propose an efficient inference process to establish a practically applicable pipeline to the actual system. Experiments on three well-known log datasets, i.e., HDFS, BGL, and Thunderbird, show that not only did LAnoBERT yield a higher anomaly detection performance compared to unsupervised learning-based benchmark models, but also it resulted in a comparable performance with supervised learning-based benchmark models.
研究动机与目标
- 解决依赖解析器的日志异常检测方法存在的信息丢失风险以及对专家模板的依赖问题。
- 开发一种稳健的无监督异常检测框架,直接从原始日志序列中学习正常日志模式,无需通过日志解析器进行预处理。
- 通过在日志数据上微调 BERT 以获取上下文嵌入,利用掩码语言建模提升异常检测性能。
- 通过设计高效的推理流水线,实现实际部署,适用于实时系统监控。
- 探索预训练 BERT 在具有不同复杂度(包括类似自然语言结构)的日志数据上的有效性。
提出的方法
- LAnoBERT 使用基于 BERT 的架构,从零开始在日志序列上预训练,采用掩码语言建模(MLM)学习正常日志模式的上下文表示。
- 模型通过基于正则表达式的预处理和 WordPiece 分词处理原始日志键,避免对日志解析器的依赖。
- 在推理阶段,异常分数基于 MLM 的预测损失和 top-k 预测概率计算,损失越高表示越异常。
- 通过测量预测标记概率与正常模式的偏离程度来检测异常,使用 top-k 概率分数的阈值进行判断。
- 通过缓存序列嵌入并重用注意力模式,该框架支持高效推理,实现实时部署。
- 模型在日志数据上使用 MLM 目标进行微调,性能评估在仅使用正常日志进行训练的无监督设置下进行。

实验结果
研究问题
- RQ1基于 BERT 的模型是否可以通过掩码语言建模有效检测系统日志异常,而无需依赖日志解析器?
- RQ2LAnoBERT 在标准基准数据集上的性能与无监督和有监督日志异常检测基线相比如何?
- RQ3在日志数据集上预训练 BERT(来自自然语言语料)是否会对异常检测性能产生提升或损害,特别是在词汇量小且结构简单的数据集上?
- RQ4无监督、无解析器的方法是否能在实际日志异常检测场景中达到与有监督模型相当的性能?
- RQ5如何设计高效的推理流水线,使基于 BERT 的异常检测在生产系统中具备实用性?
主要发现
- LAnoBERT 在 HDFS、BGL 和 Thunderbird 数据集上的所有无监督基线模型中表现最优,各项指标均取得最高 F1 分数。
- 在 BGL 数据集上,使用预训练 BERT 模型时,LAnoBERT 的 F1 分数达到 0.9020,相比从零开始训练提升了 0.0271。
- 在 HDFS 数据集上,从零开始微调的 F1 分数为 0.9304,比使用预训练 BERT 版本高出 0.0341,表明在极简日志结构上,预训练可能损害性能。
- 结果表明,仅当日志数据包含足够的语言复杂性(如词汇量超过 1,000 个)时,预训练 BERT 才具有优势,例如在 BGL 数据集中,但在 HDFS 等结构简单的数据集中则不然。
- LAnoBERT 的性能可与基于有监督学习的模型相媲美,表明通过 MLM 进行无监督预训练可与有监督方法在异常检测中实现相当的性能。
- 所提出的高效推理流水线支持实时部署,使该模型适用于实际系统监控。

更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。