Open Access iconOpen Access

ARTICLE

Context-Aware Spam Detection Using BERT Embeddings with Multi-Window CNNs

Sajid Ali1, Qazi Mazhar Ul Haq1,2,*, Ala Saleh Alluhaidan3,*, Muhammad Shahid Anwar4, Sadique Ahmad5, Leila Jamel3

1 Department of Computer Science and Engineering, Yuan Ze University, Zhongli, Taiwan
2 Department of International Bachelor Program in Informatics, Yuan Ze University, Zhongli, Taiwan
3 Department of Information Systems, College of Computer and Information Sciences, Princess Nourah bint Abdulrahman University, P.O. Box 84428, Riyadh, Saudi Arabia
4 IRC for Finance and Digital Economy, King Fahd University of Petroleum and Minerals, Dhahran, Saudi Arabia
5 EIAS Data Science & Blockchain Laboratory, College of Computer and Information Science, Prince Sultan University, Riyadh, Saudi Arabia

* Corresponding Authors: Qazi Mazhar Ul Haq. Email: email; Ala Saleh Alluhaidan. Email: email

(This article belongs to the Special Issue: Machine Learning and Deep Learning-Based Pattern Recognition)

Computer Modeling in Engineering & Sciences 2026, 146(1), 43 https://doi.org/10.32604/cmes.2026.074395

Abstract

Spam emails remain one of the most persistent threats to digital communication, necessitating effective detection solutions that safeguard both individuals and organisations. We propose a spam email classification framework that uses Bidirectional Encoder Representations from Transformers (BERT) for contextual feature extraction and a multiple-window Convolutional Neural Network (CNN) for classification. To identify semantic nuances in email content, BERT embeddings are used, and CNN filters extract discriminative n-gram patterns at various levels of detail, enabling accurate spam identification. The proposed model outperformed Word2Vec-based baselines on a sample of 5728 labelled emails, achieving an accuracy of 98.69%, AUC of 0.9981, F1 Score of 0.9724, and MCC of 0.9639. With a medium kernel size of (6, 9) and compact multi-window CNN architectures, it improves performance. Cross-validation illustrates stability and generalization across folds. By balancing high recall with minimal false positives, our method provides a reliable and scalable solution for current spam detection in advanced deep learning. By combining contextual embedding and a neural architecture, this study develops a security analysis method.

Keywords

E-mail spam detection; BERT embedding; text classification; cybersecurity; CNN

Cite This Article

APA Style
Ali, S., Haq, Q.M.U., Alluhaidan, A.S., Anwar, M.S., Ahmad, S. et al. (2026). Context-Aware Spam Detection Using BERT Embeddings with Multi-Window CNNs. Computer Modeling in Engineering & Sciences, 146(1), 43. https://doi.org/10.32604/cmes.2026.074395
Vancouver Style
Ali S, Haq QMU, Alluhaidan AS, Anwar MS, Ahmad S, Jamel L. Context-Aware Spam Detection Using BERT Embeddings with Multi-Window CNNs. Comput Model Eng Sci. 2026;146(1):43. https://doi.org/10.32604/cmes.2026.074395
IEEE Style
S. Ali, Q. M. U. Haq, A. S. Alluhaidan, M. S. Anwar, S. Ahmad, and L. Jamel, “Context-Aware Spam Detection Using BERT Embeddings with Multi-Window CNNs,” Comput. Model. Eng. Sci., vol. 146, no. 1, pp. 43, 2026. https://doi.org/10.32604/cmes.2026.074395



cc Copyright © 2026 The Author(s). Published by Tech Science Press.
This work is licensed under a Creative Commons Attribution 4.0 International License , which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
  • 11

    View

  • 3

    Download

  • 0

    Like

Share Link