TextShelter: Text Adversarial Example Defense Based on Input Reconstruction
Effective identification of textual adversarial examples is a pressing need for safeguarding application security and maintaining cybersecurity. However, most existing adversarial defense methods for natural language processing can only resist a single form of attack and lack generalizability. To address this issue, this paper proposes a simple, efficient, and versatile defense method named TextShelter, which mitigates the limitations of existing approaches that rely on specific attack assumptions and struggle to handle real-world complex adversarial samples. TextShelter integrates three modules—Homoglyph Reversion, Spelling Correction, and Reconstruction-based Backtranslation—and enhances the defense efficiency of each module through careful design and optimization. By collaboratively combining the outputs of these modules, the method achieves effective defense against multi-granularity hybrid perturbations without requiring knowledge of the target model’s structure or parameters, nor any model retraining. Experiments on three datasets including IMDb show that TextShelter can effectively restore the original output labels of adversarial examples, improving classification accuracy by up to 60%. Compared with existing mainstream defense methods, it enhances defensive capability by approximately 50%. Furthermore, TextShelter performs well in terms of sentiment preservation, robustness, and transferability, demonstrating promising extensibility.
Authors
- Nuo Cheng (ORCID: https://orcid.org/0000-0002-9220-3248)
- H. L. Li (ORCID: https://orcid.org/0009-0001-1392-9332)
- Guoqin Chang (ORCID: https://orcid.org/0000-0003-0350-7782)
- Haichang Gao (ORCID: https://orcid.org/0000-0002-4969-5718)
- Yao Zhou (ORCID: https://orcid.org/0000-0002-7696-4039)
Institutions
- Xidian University (CN)
- Technology Holding (United States) (US)
- Shaanxi Science and Technology Department (CN)
Publication Details
- Journal
- Electronics
- Published
- 2025-11-29
- DOI
- https://doi.org/10.3390/electronics14234706
- Primary Topic
- Adversarial Robustness in Machine Learning
- Type
- article
- Field-Weighted Citation Impact
- 0.00