GitHub - QData/Reevaluating-NLP-Adversarial-Examples: EMNLP Findings 2020: Reevaluating Adversarial Examples in Natural Language (original) (raw)

Reevaluating Adversarial Examples in Natural Language

This repository contains code and datasets for the experiments in "Reevaluating Adversarial Examples in Natural Language."

Files

Section 3

Section 5

To generated adjusted exmaples using TFAdjusted's attack recipe, see section_6_adjusted_attacks/recipes/textfooler_2019_jin_adjusted.py (detailed under Section 6 header).

5.1 Adjusted Constraint Application

5.2 Adversarial Training

Section 6

Running the attacks with adjusted thresholds

Both attack recipes in section_6_adjusted_attacks/recipes/*.py are easily runnable by installing TextAttack and using its --attack-from-file parameter.

For example, to run AlzantotAdjusted on 5 samples from the MR datase against TextAttack's default bert-base-uncased model fine-tuned on MR, run the following command:

textattack attack --model bert-base-uncased-mr --attack-from-file section_6_adjusted_attacks/recipes/alzantot_2018_adjusted.py --num-examples 5

Or to run TFAdjusted on 5 examples on an LSTM fine-tuned for AGNews:

textattack attack --model lstm-ag-news --attack-from-file section_6_adjusted_attacks/recipes/textfooler_jin_2019_adjusted.py --num-examples 5

These attacks have been tested using TextAttack v0.2.10.

Appendix

Citation

@article{morris2020reevaluating,
  title={Reevaluating Adversarial Examples in Natural Language},
  author={Morris, John X and Lifland, Eli and Lanchantin, Jack and Ji, Yangfeng and Qi, Yanjun},
  journal={arXiv preprint arXiv:2004.14174},
  year={2020}
}