Textual Manifold-based Defense Against Natural Language Adversarial Examples

Dang Minh Nguyen, Luu Anh Tuan
11/5/2022
cs.CLcs.CRcs.LG

Official code: dangne/tmd (11 stars, Python, MIT, last commit 2023-04-06).

Abstract

Recent studies on adversarial images have shown that they tend to leave the underlying low-dimensional data manifold, making them significantly more challenging for current models to make correct predictions. This so-called off-manifold conjecture has inspired a novel line of defenses against adversarial attacks on images.

Show full abstract

In this study, we find a similar phenomenon occurs in the contextualized embedding space induced by pretrained language models, in which adversarial texts tend to have their embeddings diverge from the manifold of natural ones. Based on this finding, we propose Textual Manifold-based Defense (TMD), a defense mechanism that projects text embeddings onto an approximated embedding manifold before classification. It reduces the complexity of potential adversarial examples, which ultimately enhances the robustness of the protected model. Through extensive experiments, our method consistently and significantly outperforms previous defenses under various attack settings without trading off clean accuracy. To the best of our knowledge, this is the first NLP defense that leverages the manifold structure against adversarial attacks. Our code is available at \url{https://github.com/dangne/tmd}.

View on arXivView PDF

Code Implementations(1)

dangne/tmdOfficial100%
MIT

[EMNLP'22] Textual Manifold-based Defense Against Natural Language Adversarial Examples

111Python, Shell3 years agoMIT

Similar Papers

Cite this paper

@article{nguyen2022textual,
  title  = {Textual Manifold-based Defense Against Natural Language Adversarial Examples},
  author = {Dang Minh Nguyen and Luu Anh Tuan},
  year   = {2022},
  eprint = {2211.02878},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2211.02878}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2211.02878.svg)](https://codeofpaper.com/paper/2211.02878)

Discussion