Comparing KNN, Logistic Regression, Random Forest and BERT Fine-Tuning for Scam Message Detection
DOI:
https://doi.org/10.61173/e19gh209Keywords:
Scam Detection, BERT Fine-Tuning, Text Classification, Attention Visualization, Logistic RegressionAbstract
Scam message detection remains a persistent challenge, particularly with the rise of adversarial content crafted to bypass traditional filters. This study compares the effectiveness of conventional classifiers—K-Nearest Neighbors (KNN), Logistic Regression, and Random Forest—using frozen BERT embeddings, against a fully fine-tuned BERT model trained end-to-end. The evaluation is conducted on a labeled dataset containing regular scam messages, adversarial scam messages generated by large language models, and legitimate non-scam texts. Among the tested models, the fine-tuned BERT achieves the highest multiclass classification accuracy of 95.83% and binary classification accuracy of 96.67%. Logistic regression also reaches 96.67% binary accuracy, offering a lightweight and computationally efficient alternative. Visualizations of attention matrices reveal that fine-tuning improves model interpretability by concentrating attention on task-relevant tokens in deeper transformer layers. These findings suggest a practical trade-off between model complexity, interpretability, and performance. While fine-tuning offers superior accuracy and insight into model behavior, traditional methods remain valuable in resource-constrained or time-sensitive scenarios. This work provides empirical evidence and visual analysis to guide the selection of text classification strategies in adversarial environments, contributing to more robust and explainable approaches for real-world scam detection.
References
ing them suitable for real-time systems and small-scale 3568–3571. IEEE, New York (2024) applications [9]. These trade-offs between accuracy, in- 2. Liu, X., Wu, H., Zhou, Y.: BERT and beyond: Advances terpretability, and efficiency reflect broader trends in NLP in transformer-based text classification. Journal of Artificial
system design and deployment [10]. Intelligence Research 75(1), 245–267 (2022) The findings also align with recent work advocating for 3. Che, J., Kim, M., Liang, P.: On the fragility of transformerhybrid approaches that combine fine-tuning with probing based models under minimal text perturbations. Transactions of strategies or selective layer freezing to achieve robust yet the Association for Computational Linguistics 12(1), 133–149
efficient models [5]. Future research could explore inte- (2024) grating adversarial training or contrastive objectives with 4. Singh, R., Wang, Y.: Balancing interpretability and robustness: lightweight classifiers to improve performance without A survey of fine-tuning and probing strategies in NLP. Neural sacrificing interpretability or resource efficiency. Dean&Francis ISSN 2959-6130
Computation 37(2), 255–278 (2025) Kong (2019) 5. Chefer, H., Gur, S., Wolf, L.: Transformer interpretability 8. Zhang, Y., Wang, T., Liu, S.: Adversarial text evasion in realbeyond attention visualization. In: Proceedings of the IEEE/ world spam detection: Challenges and solutions. In: Proceedings
CVF Conference on Computer Vision and Pattern Recognition of the Annual Conference on Computational Linguistics (2023) (CVPR), pp. 782–791. IEEE, New York (2021) 9. Tay, Y., Dehghani, M., Bahri, D., Metzler, D.: Efficient 6. Wu, C.-C., Li, H., Wang, Z., Ding, Z.: Adversarially robust transformers: A survey. arXiv preprint arXiv:2009.06732 (2020) attention in transformers. Findings of the Association for 10. Guo, H., Tang, R., Ye, Y., Li, Z., Zhang, X.: Parameter-
Computational Linguistics (ACL), 2345–2357 (2023) efficient transfer learning with diff pruning. In: Proceedings of 7. Wiegreffe, S., Pinter, Y.: Attention is not not explanation. In: the 38th International Conference on Machine Learning (ICML),
Proceedings of the 2019 Conference on Empirical Methods in pp. 3831–3841. PMLR (2021) Natural Language Processing (EMNLP), pp. 11–20. ACL, Hong
Downloads
Published
Issue
Section
License
Copyright (c) 2025 by the authors.

This work is licensed under a Creative Commons Attribution 4.0 International License.
