https://github.com/andreasmadsen/nlp-roar-interpretability
Measuring if attention is explanation with ROAR
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.9%) to scientific vocabulary
Repository
Measuring if attention is explanation with ROAR
Basic Info
- Host: GitHub
- Owner: AndreasMadsen
- License: mit
- Language: Python
- Default Branch: master
- Size: 1.73 MB
Statistics
- Stars: 22
- Watchers: 2
- Forks: 1
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
NLP ROAR Interpretability
Official code for: Evaluating the Faithfulness of Importance Measures in NLP by Recursively Masking Allegedly Important Tokens and Retraining

Install
bash
git clone https://github.com/AndreasMadsen/nlp-roar-interpretability.git
cd nlp-roar-interpretability
python -m pip install -e .
Experiments
Tasks
There are scripts for each dataset. Note that some tasks share a dataset.
Use this list to identify how to train a model for each task.
* SST: python experiments/stanford_sentiment.py
* SNLI: python experiments/stanford_nli.py
* IMDB: python experiments/imdb.py
* MIMIC (Diabetes): python experiments/mimic.py --subset diabetes
* MIMIC (Anemia): python experiments/mimic.py --subset anemia
* bABI-1: python experiments/babi.py --task 1
* bABI-2: python experiments/babi.py --task 2
* bABI-3: python experiments/babi.py --task 3
In addition to the tasks, the synthetic experiment can created with python experiments/synthetic.py.
Parameters
Each of the above scripts stanford_sentiment, stanford_nli, imdb,
mimic, and babi take the same set of CLI arguments. You can learn
about each argument with --help. The most important arguments which
will allow you to run the experiments presented in the paper are:
--importance-measure: this specifies which importance measure is used. It can be eitherrandom,mutual-information,attention,gradient, orintegrated-gradient.--seed: specifies the seed used to initialize the model.--roar-strategy: should ROAR masking be done absoloute (count) or relative (quantile),--k: the proportion of tokens in % to mask if--roar-strategy quantileis used. The number of tokens if--roar-strategy countis used.--recursive: indicates that model to use for computing the importance measure has--kset to--k---recursive-step-sizeinstead of0as used in classic ROAR.--model-typeindicates which models to used. Can be eitherrnnfor the BiLSTM-Attention model orrobertafor theRoBERTa-basemodel.
Note, for --k > 0, the reference model must already be trained. For example, in the non-recursive case, this means that a model trained with --k 0 must already available.
Running on a HPC setup
For downloading dataset dependencies we provide a download.sh script.
Additionally, we provide script for submitting all jobs to a Slurm
queue, in batch_jobs/. Note again, that the ROAR script assume
there are checkpoints for the baseline --k 0 models.
The jobs automatically use $SCRATCH/nlproar as the presistent dir.
MIMIC
See https://mimic.physionet.org/gettingstarted/access/ for how to access MIMIC.
You will need to download DIAGNOSES_ICD.csv.gz and NOTEEVENTS.csv.gz and
place them in mimic/ relative to your presistent dir.
Owner
- Name: Andreas Madsen
- Login: AndreasMadsen
- Kind: user
- Location: Copenhagen, Denmark
- Company: MILA
- Website: https://andreasmadsen.github.io/
- Twitter: andreas_madsen
- Repositories: 151
- Profile: https://github.com/AndreasMadsen
Researching interpretability for Machine Learning because society needs it.
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Issues and Pull Requests
Last synced: over 1 year ago
All Time
- Total issues: 5
- Total pull requests: 58
- Average time to close issues: 9 months
- Average time to close pull requests: 19 days
- Total issue authors: 2
- Total pull request authors: 3
- Average comments per issue: 0.4
- Average comments per pull request: 2.19
- Merged pull requests: 51
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- AndreasMadsen (2)
- ncmeade (1)
Pull Request Authors
- AndreasMadsen (31)
- vaibhavad (4)
- ncmeade (4)