A Signal-Based Comparative Analysis Of Transformer And Cnn Architectures For Natural Language Processing Applications
DOI:
https://doi.org/10.29284/ryks4174Keywords:
Transformers, convolutional neural networks, natural language processing, robustness, hate speech detection.Abstract
Transformer-based networks and convolutional neural networks are popular sequence modeling models in natural language processing and have not been fully studied in terms of their resistance to various linguistic perturbations. This study presents a comparative analysis of CNN and Transformer models using a diagnostic hate speech detection benchmark comprising 3,728 linguistically controlled test cases. A character-level CNN and a token-based Transformer were evaluated under identical experimental conditions. The Transformer achieved higher overall performance, with an accuracy of 76.9% and an F1-score of 0.80, while the CNN achieved an accuracy of 71.4% and an F1-score of 0.75. The Transformer also exhibited a lower false negative rate of 19.6%, whereas the CNN showed a false negative rate of 28.4%. Functional analysis indicated that the Transformer performed better on semantically complex constructions such as negation and quotation. In contrast, the CNN demonstrated greater robustness to spelling-based perturbations, attaining accuracy values of up to 84.6% under character-level noise. These findings indicate that architectural effectiveness depends on the dominant characteristics of the linguistic input and the nature of the perturbation. The results provide quantitative evidence to support informed architecture selection for NLP applications requiring robustness to linguistic variability.
References
1. Liu, Y., Sun, G., Qiu, Y., Zhang, L., Chhatkuli, A. and Van Gool, L., 2021. Transformer in convolutional neural networks. arXiv preprint arXiv:2106.03180, 3.
2. Arkin, E., Yadikar, N., Xu, X., Aysa, A. and Ubul, K., 2023. A survey: object detection methods from CNN to transformer. Multimedia Tools and Applications, 82(14), pp.21353-21383.
3. Li, C., Huang, X., Song, R., Qian, R., Liu, X. and Chen, X., 2022. EEG-based seizure prediction via Transformer guided CNN. Measurement, 203, p.111948.
4. Thomas, J.B., Chaudhari, S.G. and Verma, N.K., 2023. CNN-based transformer model for fault detection in power system networks. IEEE Transactions on Instrumentation and Measurement, 72, pp.1-10.
5. Wolf, T., Debut, L., Sanh, V., Chaumond, J., Delangue, C., Moi, A., Cistac, P., Rault, T., Louf, R., Funtowicz, M. and Davison, J., 2020, October. Transformers: State-of-the-art natural language processing. In Proceedings of the 2020 conference on empirical methods in natural language processing: system demonstrations (pp. 38-45).
6. Rothman, D. and Gulli, A., 2021. Transformers for natural language processing (Vol. 267). Packt Publishing.
7. Tunstall, L., Von Werra, L. and Wolf, T., 2022. Natural language processing with transformers. " O'Reilly Media, Inc.".
8. Canchila, S., Meneses-Eraso, C., Casanoves-Boix, J., Cortés Pellicer, P. and Castello Sirvent, F., 2024. Natural language processing: An overview of models, transformers and applied practices.
9. Hajri, F. and Fradi, H., 2022, November. Vision transformers for road accident detection from dashboard cameras. In 2022 18th IEEE international conference on advanced video and signal based surveillance (AVSS) (pp. 1-8). IEEE.
10. Akinpelu, S., Viriri, S. and Haroon Yousaf, M., 2025. Swintser: An improved bilingual speech emotion recognition using shift window transformer. Cognitive Computation, 17(4), p.129.
11. Vidyasagar, K.C., Kumar, K.R., Sai, G.A., Ruchita, M. and Saikia, M.J., 2024. Signal to image conversion and convolutional neural networks for physiological signal processing: A review. Ieee Access, 12, pp.66726-66764.
12. Moslhi, A.M., Aly, H.H. and ElMessiery, M., 2024. The impact of feature extraction on classification accuracy examined by employing a signal transformer to classify hand gestures using surface electromyography signals. Sensors, 24(4), p.1259.
13. Ali, O.S. and Rahim, L., 2025. A Comparative Study of Machine Learning Techniques for AE-Based Corrosion Detection with Emphasis on Transformer Models. International Journal of Advanced Computer Science & Applications, 16(7).
14. Röttger, P., Vidgen, B., Nguyen, D., Waseem, Z., Margetts, H. and Pierrehumbert, J.B., 2021. HateCheck: Functional tests for hate speech detection models. GitHub repository: HateCheck Dataset. Available at: https://github.com/paul-rottger/hatecheck-data.
15. Mahum, R., Ganiyu, I., Hidri, L., El-Sherbeeny, A.M. and Hassan, H., 2025. A novel Swin transformer based framework for speech recognition for dysarthria. Scientific Reports, 15(1), p.20070.
16. Soleimani, S. and Al Osman, H., 2025. Transformer-based bimodal emotion recognition: signal measurement and transformer fusion approach. IEEE Transactions on Instrumentation and Measurement.
17. Jin, Z., Xing, Z., Wang, Y., Fang, S., Gao, X. and Dong, X., 2023. Research on emotion recognition method of cerebral blood oxygen signal based on CNN-transformer network. Sensors, 23(20), p.8643.
18. Sato, M., Huang, Z., Guo, A. and Ma, J., 2025, October. Emotion Recognition based on Multimodal Physiological Signals using a CNN-Transformer Model. In 2025 IEEE Cyber Science and Technology Congress (CyberSciTech) (pp. 393-400). IEEE.
19. Ansari, S., Mahmoud, S., Majzoub, S., Almajali, E., Jarndal, A. and Bonny, T., 2025. A Novel LSTM Architecture for Automatic Modulation Recognition: Comparative Analysis with Conventional Machine Learning and RNN-Based Approaches. IEEE Access.
20. Chen, Q., Zhang, F., Wang, Y., Yu, Q., Lang, G. and Zeng, L., 2025. Bearing fault diagnosis based on efficient cross space multiscale CNN transformer parallelism. Scientific Reports, 15(1), p.12344.
21. Verma, P. and Pilanci, M., 2024. Towards signal processing in large language models. arXiv preprint arXiv:2406.10254.
22. Wang, D., Lin, M., Zhang, X., Huang, Y. and Zhu, Y., 2023. Automatic modulation classification based on CNN-transformer graph neural network. Sensors, 23(16), p.7281.
Downloads
Published
Issue
Section
License

This work is licensed under a Creative Commons Attribution 4.0 International License.
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.

