weifanjiang / nlp_adversarial_attack

Course project for COMS 6998-10 at Columbia University, generating black-box NLP adversarial examples based on sentence-level perturbations, saliency evaluation and genetic algorithm.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NLP Adversarial Attack

Course Project for COMS 6998-10: Robustness and Security in ML Systems, Spring 2020 at Columbia University.

Group members:

  • Weifan Jiang (wj2301)
  • Haoxuan Wu (hw2754)

Dependencies

Please install dependencies including stanford NLP with English models, keras-preprocessing, google cloud translation API (may need to set up an account and provide credit card information), and tensorflow version 1 (our project is incompatible with version 2 or greater), etc.

Other dependencies can be downloaded following prompt.

Input data

Please download this zip file from google drive (Columbia account required), and unzip it in the root of repository.

Usage

Our implementation of the Sentence-level genetic algorithm with salency analysis, along with other helper functions is in sentence_level_genetic_attack.py. Please change the envrionmental variables in the script accordingly (dataset name, google cloud API credentials, etc.).

A demostration on how to use our attack is in sentence_level_genetic_attack_demo.ipynb. The example model used is a WordCNN trained with imdb dataset. sentence_level_genetic_attack_demo.pdf is the result of the notebook exported to pdf.

Document

  • presentation slides

  • Report for project at: report/Sentence_Level_Adversarial_Attack_on_Natural_Language_Processing_Models.pdf

Credit

The pretrained models and preprocessing of input data are from Alzantot Et Al.. Our forked version of their original repo is here.

About

Course project for COMS 6998-10 at Columbia University, generating black-box NLP adversarial examples based on sentence-level perturbations, saliency evaluation and genetic algorithm.


Languages

Language:Jupyter Notebook 55.1%Language:Python 44.9%