Incorporate Transformer-Based Models for Anomaly Detection
Abstract
This paper explores the effectiveness of Transformer-based models, specifically the Time-Series Transformer (TST) and Temporal Fusion Transformer (TFT), for anomaly detection in streaming data. We review related work on anomaly detection models, highlighting traditional methods' limitations in speed, accuracy, and scalability. While LSTM Autoencoders are known for their ability to capture temporal patterns, they suffer from high memory consumption and slower inference times. Though efficient in terms of memory usage, the Matrix Profile provides lower performance in detecting anomalies. To address these challenges, we propose using Transformer-based models, which leverage the self-attention mechanism to capture long-range dependencies in data, process sequences in parallel, and achieve superior performance in both accuracy and efficiency. Our experiments show that TFT outperforms the other models with an F1-score of 0.92 and a Precision-Recall AUC of 0.71, demonstrating significant improvements in anomaly detection. The TST model also shows competitive performance with an F1-score of 0.88 and Precision-Recall AUC of 0.68, offering a more efficient alternative to LSTMs. The results underscore that Transformer models, particularly TST and TFT, provide a robust solution for anomaly detection in real-time applications, offering improved performance, faster inference times, and lower memory usage than traditional models. In conclusion, Transformer-based models stand out as the most effective and scalable solution for large-scale, real-time anomaly detection in streaming time-series data, paving the way for their broader application across various industries. Future work will further focus on optimizing these models and exploring hybrid approaches to enhance detection capabilities and real-time performance.
Keywords
Full Text:
PDFReferences
E. P. A. Eka and M. Z. Zakaria, “Real-Time Outlier Detection in Fast-Moving Data Streams,” International Journal of Advances in Artificial Intelligence and Machine Learning, vol. 1, no. 1, pp. 19–27, Nov. 2024, doi: 10.58723/IJAAIML.V1I1.287.
Eren, Y., & Küçükdemiral, İ. (2024). A comprehensive review of deep learning approaches for short-term load forecasting. Renewable and Sustainable Energy Reviews, 189, 114031. https://doi.org/https://doi.org/10.1016/j.rser.2023.114031
Ahmed, S., Nielsen, I. E., Tripathi, A., Siddiqui, S., Ramachandran, R. P., & Rasool, G. (2023). Transformers in Time-Series Analysis: A Tutorial. Circuits, Systems, and Signal Processing, 42(12), 7433–7466. https://doi.org/10.1007/s00034-023-02454-8
Nazir, A., Shaikh, A. K., Shah, A. S., & Khalil, A. (2023). Forecasting energy consumption demand of customers in smart grid using Temporal Fusion Transformer (TFT). Results in Engineering, 17, 100888. https://doi.org/https://doi.org/ 10.1016/j.rineng.2023.100888
Shi, D., Zhao, J., Wang, Z., Zhao, H., Wang, J., Lian, Y., & Burke, A. F. (2023). Spatial-Temporal Self-Attention Transformer Networks for Battery State of Charge Estimation. Electronics, 12(12). https://doi.org/10.3390/electronics12122598
Zhang, Z., Yao, Y., Hutabarat, W., Farnsworth, M., Tiwari, D., & Tiwari, A. (2024). Time Series Anomaly Detection in Vehicle Sensors Using Self-Attention Mechanisms. IEEE Transactions on Intelligent Transportation Systems, 25(11), 15964–15976. https://doi.org/10.1109/TITS.2024.3415435
Luo, H., Zheng, Y., Chen, K., & Zhao, S. (2024). Probabilistic Temporal Fusion Transformers for Large-Scale KPI Anomaly Detection. IEEE Access, 12, 9123–9137. https://doi.org/10.1109/ACCESS.2024.3353201
Dokuz, A. S. (2022). Weighted spatio-temporal taxi trajectory big data mining for regional traffic estimation. Physica A: Statistical Mechanics and Its Applications, 589, 126645. https://doi.org/https://doi.org/10.1016/j.physa.2021.126645
Dewi, D., Singh, H., Periasamy, J., Kurniawan, T., Henderi, H., & Hasibuan, M. (2024). Scalable Machine Learning Approaches for Real-Time Anomaly and Outlier Detection in Streaming Environments. Journal of Applied Data Sciences, 5(4), 1949-1962. doi:https://doi.org/10.47738/jads.v5i4.444
Diallo Ramatoulaye and Edalo, C. and A. O. O. (2025). Machine Learning Evaluation of Imbalanced Health Data: A Comparative Analysis of Balanced Accuracy, MCC, and F1 Score. In E. Awe O. Olawale and A. Vance (Ed.), Practical Statistical Learning and Data Science Methods: Case Studies from LISA 2020 Global Network, USA (pp. 283–312). Springer Nature Switzerland. https://doi.org/10.1007/978-3-031-72215-8_12
Shuvo, M. M. H., Islam, S. K., Cheng, J., & Morshed, B. I. (2023). Efficient Acceleration of Deep Learning Inference on Resource-Constrained Edge Devices: A Review. Proceedings of the IEEE, 111(1), 42–91. https://doi.org/10.1109/ JPROC.2022.3226481
Ye, G. (2024). De novo drug design as GPT language modeling: large chemistry models with supervised and reinforcement learning. Journal of Computer-Aided Molecular Design, 38(1), 20. https://doi.org/10.1007/s10822-024-00559-z
Kundu, S., & Sundaresan, S. (2021). AttentionLite: Towards Efficient Self-Attention Models for Vision. ICASSP 2021 - 2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2225–2229. https://doi.org/10.1109/ICASSP39728.2021.9415117
DOI: https://doi.org/10.47738/jads.v6i3.762
Refbacks
- There are currently no refbacks.

Journal of Applied Data Sciences
| ISSN | : | 2723-6471 (Online) |
| Publisher | : | Bright Publisher |
| Website | : | http://bright-journal.org/JADS |
| : | taqwa@amikompurwokerto.ac.id (principal contact) | |
| support@bright-journal.org (technical issues) |
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0




.png)