On-Device LLM Reasoning for IoT Anomaly Detection in Fog Computing Environments

Authors

Keywords:

fog computing, environment-behaviour, anomaly detection, on-device LLM

Abstract

Environmental monitoring systems detect anomalies but rarely explain them in ways that change human behavior. This research shows a fog
computing system with three levels. It uses an Isolation Forest to identify issues, and then a Llama 3.2 3B model to provide explanations. The system
successfully identified 97% of the true anomalies (precision of 0.97), found 60% of all anomalies (recall of 0.60), maintained a balance between
precision and recall (F1 of 0.74), and took only 10.43 milliseconds per anomaly. All processed offline on a local fog node with no cloud dependency.

References

Abdulkadhim, M., & Repas, S. R. (2026). Introducing LEAF: LLM Edge Assessment Framework for Generative AI on the Edge. Machine Learning and Knowledge Extraction, 8(2), 48. https://doi.org/10.3390/make8020048

Aini, Q., Manongga, D., Rahardja, U., Sembiring, I., & Li, Y.-M. (2024). Understanding behavioral intention to use of air quality monitoring solutions with emphasis on technology readiness. International Journal of Human–Computer Interaction, 41(8), 5079–5099. https://doi.org/10.1080/10447318.2024.2357860

Al-Atawi, A. A. (2024). Enhancing data management and real-time decision making with IoT, cloud, and fog computing. IET Wireless Sensor Systems, 14(6), 539–562. https://doi.org/10.1049/wss2.12099

Alabbadi, A., & Bajaber, F. (2025). An intrusion detection system over the IoT data streams using eXplainable artificial intelligence (XAI). Sensors, 25(3), 847. https://doi.org/10.3390/s25030847

Bainomugisha, E., Ssematimba, J., & Okure, D. (2023). Design considerations for a distributed low-cost air quality sensing system for urban environments in low-resource settings. Atmosphere, 14(2), 354. https://doi.org/10.3390/atmos14020354

Bhandari, K. S., Seo, C., & Cho, G. H. (2020, September). Towards sensor-cloud based efficient smart healthcare monitoring framework using machine learning. In The 9th international conference on smart media and applications (pp. 380-383).

Binetti, M. S., Uricchio, V. F., & Massarelli, C. (2025). Isolation Forest for environmental monitoring: A data-driven approach to land management. Environments, 12(4), 116. https://doi.org/10.3390/environments12040116

Blackman, A., & Hoffmann, B. (2025). Can smartphone app trainings help reduce exposure to air pollution? Experimental evidence from Bogotá. Land Economics, 101(4), 499–520. https://le.uwpress.org/content/101/4/499

Jang, S., & Morabito, R. (2025). Edge-first language model inference: Models, metrics, and tradeoffs. arXiv preprint arXiv:2505.16508. https://arxiv.org/abs/2505.16508

Kazem, A., Pierre, G., & Longuevergne, L. (2025). Enhancing environmental observatories with fog computing. Frontiers in Environmental Science, 13. https://doi.org/10.3389/fenvs.2025.1568016

Kureshi, R. R., Thakker, D., Mishra, B. K., & Barnes, J. (2023). From raising awareness to a behavioral change: A case study of indoor air quality improvement using IoT and COM-B model. Sensors, 23(7), 3613. https://doi.org/10.3390/s23073613

Lamaakal, I., et al. (2025). Tiny language models for automation and control: Overview, potential applications, and future research directions. Sensors, 25(5), 1318. https://doi.org/10.3390/s25051318

Liu, F. T., Ting, K. M., & Zhou, Z. H. (2008). Isolation forest. In Proceedings of the 2008 Eighth IEEE International Conference on Data Mining (pp. 413–422). IEEE. https://doi.org/10.1109/ICDM.2008.17

Magableh, M., Marie, Z., Mohamed, R. R., Bin Ibrahim, M. H., Jusoh, J. A., & Kumar, R. (2023). Using Arduino IoT modules as a low cost environmental research monitoring system. 2023 International Conference on Computer Science and Emerging Technologies (CSET), 1–6. https://doi.org/10.1109/CSET58993.2023.10346624

Muneeb, M., Ko, K.-M., & Park, Y.-H. (2021). A fog-computing architecture with multi-layer for computing-intensive IoT applications. Applied Sciences, 11(24), 11585. https://doi.org/10.3390/app112411585

Nguyen, T., & Nguyen, T. (2025). An evaluation of LLMs inference on popular single-board computers. arXiv preprint arXiv:2511.07425. https://arxiv.org/abs/2511.07425

Obidiagha, C. C., Rahouti, M., Drid, H., Hamouid, K., Medjadba, Y., & Jagatheesaperumal, S. K. (2025). iForestExplain: A dual-stage Isolation Forest framework with explainable AI for DoS/DDoS anomaly detection in IoT networks. Cluster Computing, 28, 214. https://doi.org/10.1007/s10586-025-05365-2

Olsson, A. (2025). Evaluating locally hosted large language models for scientific report processing. KTH Royal Institute of Technology. https://www.diva-portal.org/smash/get/diva2:1971939/FULLTEXT01.pdf

Sharma, R., & Mehta, M. (2025). Adaptive and explainable AI agents for anomaly detection in critical IoT infrastructure using LLM-enhanced contextual reasoning. arXiv preprint arXiv:2510.03859. https://arxiv.org/abs/2510.03859

Stanko, A., Wieczorek, W., Mykytyshyn, A., Holotenko, O., & Lechachenko, T. (2024). Real-time air quality management: Integrating IoT and fog computing for effective urban monitoring. CEUR Workshop Proceedings, 3742. https://ceur-ws.org/Vol-3742/paper23.pdf

Zhang, M., Shen, X., Cao, J., Cui, Z., & Jiang, S. (2025). EdgeShard: Efficient LLM inference via collaborative edge computing. IEEE Internet of Things Journal, 12(12), 13119–13131. https://doi.org/10.1109/JIOT.2025.3529750

Zou, X., Jiang, X., Huang, R., & Zhao, J. (2025). Towards generalizable context-aware anomaly detection: A large-scale benchmark in cloud environments. arXiv preprint arXiv:2508.01844. https://arxiv.org/abs/2508.01844

Downloads

Published

2026-05-06

How to Cite

Gyawali, A., Singh Bhandari, K., & Abdulhakim Al-Absi, A. (2026). On-Device LLM Reasoning for IoT Anomaly Detection in Fog Computing Environments. Environment-Behaviour Proceedings Journal, 11(37). Retrieved from https://ebpj.e-iph.co.uk/index.php/EBProceedings/article/view/7899