Adversarial attacks in the text domain pose a serious risk to the integrity of Natural Language Processing (NLP) systems. In this study, we propose "TextGuard," a unique approach to detect hostile instances in NLP, based on the Local Outlier Factor (LOF) algorithm. This paper compares TextGuard's performance against traditional NLP classifiers like LSTM, CNN, and transformer-based models, experimentally verifying its effectiveness across various real-world datasets. To contextualize our findings and demonstrate its superiority, TextGuard significantly surpasses earlier state-of-the-art methods like DISP and FGWS, achieving F1 recognition accuracy scores up to 94.8%. Consequently, this sets a new benchmark as the first application of the LOF technique for adversarial example identification within the text domain.
Copyrights © 2025