This project uses Python 3.8
-
Clone this repository
git clone https://github.com/ShriyaA/explainable-nlp-robustness.git
-
Create a virtual environment and activate it (Recommended)
cd explainable-nlp-robustness python -m venv venv source venv/bin/activate
-
Install required packages
pip install -r requirements.txt
-
Create output folder
mkdir output
python src/__main__.py visualize input.txt
Word Deletion:
python src/__main__.py generate data/glue-sst2-validation.csv --attack_type word_deletion
Misspelling:
python src/__main__.py generate data/glue-sst2-validation.csv --attack_type misspelling
Misspelling
python src/__main__.py greedy-search data/glue-sst2-validation.csv --target_selection most --attack_type misspelling --clean_text True --combination_method sum --output_file ./output/search.csv
python src/__main__.py plotting --scoring_method cosine
python src/__main__.py sent-similarity
The input file should be a two-column csv file with text sample in the first column and true label in the second column. Example:
it 's a charming and often affecting journey .,1
unflinchingly bleak and desperate,0
The output is written to a file called 'output.html' in the output directory. Output is always written in append mode. The html file can be opened in the browser and shows the output in the same format created by captum's visualize_text
function.