Home

Awesome

Textual Manifold-based Defense Against Natural Language Adversarial Examples

This is the official GitHub repository for the following paper:

Textual Manifold-based Defense Against Natural Language Adversarial Examples.
Dang Minh Nguyen and Anh Tuan Luu.
Empirical Methods in Natural Language Processing (EMNLP), 2022.

Installation

To install the required dependencies for this project, run the following commands:

conda env create -f environment.yml
conda activate tmd

Training

There are two main training steps in our paper:

  1. Fine-tuning language models (LMs) on downstream tasks (optional)
  2. Training InfoGAN to approximate the natural embedding manifolds of the target LMs

We use wandb sweep to monitor both the fine-tuning of LMs and the training of InfoGANs. The YAML configuration files for these processes can be found in ./src/finetune and ./src/train, respectively, and can be run using the following wandb command:

wandb sweep <yaml_file>.yaml

Evaluation

To evaluate the robustness of our defenses against different attacks, we follow the recommendations of Li et al. (2021). Their code can be found here.