TextGrad: Advancing Robustness Evaluation in NLP by Gradient-Driven Optimization

Bairu Hou, Jinghan Jia, Yihua Zhang, Guanhua Zhang, Yang Zhang +2 more
12/19/2022
cs.CL

Official code: UCSB-NLP-Chang/TextGrad (24 stars, Python, last commit 2023-09-20).

Abstract

Robustness evaluation against adversarial examples has become increasingly important to unveil the trustworthiness of the prevailing deep models in natural language processing (NLP). However, in contrast to the computer vision domain where the first-order projected gradient descent (PGD) is used as the benchmark approach to generate adversarial examples for robustness evaluation, there lacks a principled first-order gradient-based robustness evaluation framework in NLP.

Show full abstract

The emerging optimization challenges lie in 1) the discrete nature of textual inputs together with the strong coupling between the perturbation location and the actual content, and 2) the additional constraint that the perturbed text should be fluent and achieve a low perplexity under a language model. These challenges make the development of PGD-like NLP attacks difficult. To bridge the gap, we propose TextGrad, a new attack generator using gradient-driven optimization, supporting high-accuracy and high-quality assessment of adversarial robustness in NLP. Specifically, we address the aforementioned challenges in a unified optimization framework. And we develop an effective convex relaxation method to co-optimize the continuously-relaxed site selection and perturbation variables and leverage an effective sampling method to establish an accurate mapping from the continuous optimization variables to the discrete textual perturbations. Moreover, as a first-order attack generation method, TextGrad can be baked into adversarial training to further improve the robustness of NLP models. Extensive experiments are provided to demonstrate the effectiveness of TextGrad not only in attack generation for robustness evaluation but also in adversarial defense.

View on arXivView PDF

Code Implementations(1)

242PythonDec 24, 20223 years ago

Similar Papers

Cite this paper

@article{hou2022textgrad,
  title  = {TextGrad: Advancing Robustness Evaluation in NLP by Gradient-Driven Optimization},
  author = {Bairu Hou and Jinghan Jia and Yihua Zhang and Guanhua Zhang and Yang Zhang and Sijia Liu and Shiyu Chang},
  year   = {2022},
  eprint = {2212.09254},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2212.09254}
}

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/2212.09254.svg)](https://codeofpaper.com/paper/2212.09254)

Discussion