Research Article

Spam/Ham email classification using BERT

Siwei Zhang*
The Chinese University of Hong Kong

* Corresponding author: [email protected]

Abstract

Email is a popular method for communicating with each other. However, as sending email is free of charge as long as an email server and a domain name are available, spam mail is becoming a critical problem in the email network. Conventionally, the industry uses spam filters based on rules and Bayesian inference to counteract spam mail, reaching an accuracy of 98.76%, which is far from satisfactory. Hence, to better protect email users from unsolicited messages containing advertisements, sensitive content, phishing content, and viruses, a new approach is proposed, in which email content is filtered by a spam detector using bidirectional encoder representations from transformers (BERT). BERT is a new language representation model published by Google that has achieved great success because of its powerful capabilities in understanding natural language. After the model is trained on a corpus from Kaggle, the spam detector equipped with the BERT model reaches a binary accuracy of 99.40% when classifying spam mail.

Keywords: machine learning; NLP; BERT; spam detector.
Published: June 14, 2023
DOI: 10.54254/2755-2721/6/20230571
Volume: ACE Vol.6
pp. 1189-1195
Download PDF

References

  1. Guo, Y., Mustafaoglu, Z., and Koundal, D 2022 Journal of Computational and Cognitive Engineering. Wang, F., Ko, R., and Mickens, J 2019 In 16th USENIX Symposium on Networked Systems Design and Implementation (NSDI 19) 615-630.
  2. Gordon C, and Thomas L 2007 Online Supervised Spam Filter Evaluation. ACM Transactions on Information Systems 25 3 11 (Preprint https://doi.org/10.1145/1247715.1247717)
  3. John G 2004 How to beat an adaptive spam filter MIT Spam Conference Cambridge
  4. Cindy C, Annalee N 2011 Noncommercial Email Lists: Collateral Damage in the Fight against Spam Electronic Frontier Foundation: White Paper Electronic Frontier Foundation
  5. Jacob D, Ming-Wei C, Kenton L, and Kristina T 2019 Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies Minneapolis Association for Computational Linguistics 1 4171–4186 (Preprint https://doi.org/10.18653/v1/n19-1423)
  6. Ashish V, Noam S, Niki P, Jakob U, Llion J, Aidan G, Lukasz K, and Illia P 2017 Attention is All You Need Advances in Neural Information Processing Systems 30 (Preprint https://doi.org/10.48550/arXiv.1706.03762)
  7. The University of California, Berkeley Data 100 Fall 19, Project 2 2019 Kaggle
  8. Turc I, Ming-Wei C, Kenton L, and Kristina T 2019 Well-Read Students Learn Better: On the Importance of Pre-Training Compact Models Preprint https://doi.org/10.48550/arXiv.1908.08962
  9. Alec R, Karthik N, Tim S, and Ilya S 2020 Improving Language Understanding with Unsupervised Learning OpenAI
  10. Martín Abadi et al. 2015 TensorFlow: Large-scale machine learning on heterogeneous systems Preprint https://doi.org/10.5281/zenodo.4724125