• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

计算机工程与科学 ›› 2026, Vol. 48 ›› Issue (5): 914-924.doi: 10.3969/j.issn.1007-130X.2026.05.015

• 人工智能与数据挖掘 • 上一篇    下一篇

基于变分Transformer的时间序列异常检测

薛安荣,陈杰


  

  1. (江苏大学计算机科学与通信工程学院,江苏 镇江 212013) 

  • 收稿日期:2024-03-27 修回日期:2024-09-30 出版日期:2026-05-25 发布日期:2026-05-21
  • 基金资助:
    国家重点研发计划(2018YFB0104400)

Time series anomaly detection based on variational Transformer

XUE Anrong,CHEN Jie   

  1. (School of Computer Science and Communication Engineering,Jiangsu University,Zhenjiang  212013,China)
  • Received:2024-03-27 Revised:2024-09-30 Online:2026-05-25 Published:2026-05-21

摘要: 时间序列异常检测可以发现监测系统中的异常,及时采取必要措施可减少故障和保护系统安全。然而,现有的时序异常检测模型对时序数据之间非线性关联的处理效果不佳。为此,提出基于变分Transformer与高斯核的双分支学习模型,分别构建序列关联和局部关联,以重建误差与2种关联之间的差异度量为异常得分,并通过k-means算法自动确定异常阈值。此外,通过校正Transformer中位置编码以减少重构误差。在5个公开数据集上与9个基线模型的对比实验结果表明,所提模型在大多数情况下优于基线模型,而且是唯一在5个数据集上的F1值均超过90%的模型,其在各数据集上F1的平均值比最好的基线模型高2.27个百分点。实验结果表明,所提模型在准确性上具有显著优势,能够有效提高时间序列异常检测的准确性和可靠性。

关键词: 异常检测, 多维时间序列分析, Transformer模型, 高斯核函数, 变分自动编码器

Abstract: Time series anomaly detection can identify anomalies in monitoring systems, allowing for timely measures to reduce failures and ensure system security. However, existing time series anomaly detection models struggle to effectively handle the nonlinear associations between time series data. To address this issue, a dual-branch learning model based on variational Transformer and Gaussian kernel is proposed, which constructs sequence associations and local associations separately. The difference metric between reconstruction errors and the two associations is used as the anomaly score, and the k-means algorithm is employed to automatically determine the anomaly threshold. Additionally, the position encoding in the Transformer is calibrated to reduce reconstruction errors. Comparative experimental results against nine baseline models on five public datasets  indicate on various datasets, which the proposed model outperforms baseline models in most cases and is the only model that achieves an F1 -score exceeding 90% across all five datasets, with an average F1 -score on various datasets, which is 2.27 percentage points higher than that of the best baseline model. This indicates that the proposed model has significant advantages in correctness and can effectively improve the reliability and precision of time series anomaly detection.


Key words: anomaly detection, multi-dimensional time series analysis, Transformer model, Gaussian kernel function, variational auto-encoder