An accurate spam email detection mechanism using XLNet
Document Type
Article
Publication Date
2026
Department/School
Information Security and Applied Computing
Publication Title
International Journal of Data Science and Analytics
Abstract
Spam detection is crucial for email security. It protects individuals and organizations from unsolicited and potentially malicious emails, which can lead to significant financial losses. Existing spam email detection techniques struggle with the high volume, complexity, and variability of natural language and require extensive feature engineering, resulting in poor performance, including misclassifying legitimate emails as spam, missing some spam emails, and the inability to detect new types of spam emails. This paper proposes a novel spam email detection mechanism based on XLNet, a pre-trained language model that has not been previously explored for this purpose. By fine-tuning XLNet on a labeled dataset of spam and non-spam emails without requiring hand-engineered features, our innovative approach streamlines the detection process. The model predicts the class of previously unseen emails by leveraging the fine-tuned XLNet architecture. The proposed model is evaluated on various benchmark datasets and compared with state-of-the-art models. The model outperforms or is at least comparable to the state-of-the-art models, achieving accuracy, area under the receiver operating characteristic curve (AUC), and F1 scores of 0.9869, 0.9817, and 0.9869 on the SpamAssassin dataset; 0.9892, 0.9893, and 0.9892 on the Enron dataset; 0.9944, 0.9967, and 0.9944 on the Ling-Spam dataset; and 0.9888, 0.9889, and 0.9888 on the combined dataset, respectively.
Link to Published Version
Recommended Citation
Shrestha, N., Oluoch, J., Sun, W., Kim, J., & Caushaj, E. (2026). An accurate spam email detection mechanism using XLNet. International Journal of Data Science and Analytics, 21(1), article 21. https://doi.org/10.1007/s41060-025-00887-9
Comments
J. Oluoch is a faculty member in EMU's School of Information Security and Applied Computing.