Skip to content

omyokun/On-explaining-with-attention-matrices

Repository files navigation

On explaining with attention matrices

This code is for On explaining with attention matrices experiments, we based ourselves on the code1 of Sarah Wiegreffe & Yuval Pinter for their paper Attention is not not Explanation and on the code2 supplied by Sarthak Jain & Byron Wallace for their paper Attention is not Explanation.

Getting started

We use the same dependencies as Jain & Wallace. Please consult their installation guidelines for the code. Please download the code in a folder named Transparency, and ensure to export the meta-directory into which you clone Transparency to your PYTHONPATH to enable correct import functionality. If the cloned directory is located at /home/users/Transparency/, then run export PYTHONPATH='/home/users' from command line or add it to your ~/.bashrc. (If you get the following error ModuleNotFoundError: No module named 'Transparency', it means that your PYTHONPATH is not set).

Data Preprocessing

We use the same prerequisites as Jain & Wallace for the SST, IMDb, AgNews, and 20News datasets. Please consult the preprocessing guidelines provided here.

First experiment

${1} can be SST, IMDb, AgNews, or 20News ${2} can be averageor lstm

  • python train_and_run_experiments_bc.py --dataset ${1} --data_dir . --output_dir output/ --attention frozen --encoder ${2}

Second experiment

${1} can be SST, IMDb, AgNews, or 20News ${2} can be averageor lstm ${3} lambda value for example 0.001 ${4} path to saved model with attentions and predictions

  • python train_and_run_experiments_bc.py --dataset ${1} --data_dir . --output_dir output/ --encoder ${2} --adversarial --lmbda ${3} --gold_label_dir ${4} --n_iters 80

Third experiment

Please, before executing this command, uncomment some lines indicated in comments in [model/modules/Decoder.py] ${1} can be SST, IMDb, AgNews, or 20News ${2} can be averageor lstm

  • python train_and_run_experiments_bc.py --dataset ${1} --data_dir . --output_dir output/ --attention frozen --encoder ${2}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors