This library contains a Pytorch implementation of Differentiable Masking Explainer (Diffmask), as presented in [1](https://arxiv.org/abs/2004.14992).
- python>=3.6
- pytorch>=1.5: https://pytorch.org
- pytorch-lightning==0.7.3: https://pytorch-lightning.readthedocs.io
- transformers>=2.9.0: https://github.com/huggingface/transformers
- torch-optimizer>=0.0.1a9: https://github.com/jettify/pytorch-optimizer
- matplotlib>=3.1.1: https://matplotlib.org
Notice that older or newer version could work but they were not tested.
To install, run
$ python setup.py install
To donwload datasets run
$ ./scripts/download_datasets.sh
To download models, use the following link. Note that these are not the exaclt same models used for the paper.
- diffmask: Contains the source code for DiffMask.
We have 5 jupyter notebbok with the code for reproducing some of the results from our work [1]. Note that since i) the code was refactored and ii) we were not able to realise the exact same models used for the paper, re-generated plots and tables might differ from the ones in our work.
- QuestionAnsweringSquadAnalysis Plots and analysis using other methods of a BERT large model for question answering.
- QuestionAnsweringSquadDiffMaskAnalysis Plots and analysis using DiffMask of a BERT large model for question answering.
- SentimentClassificationSSTAnalysis Plots and analysis using other methods of a BERT base model for sentiment analisys.
- SentimentClassificationSSTDiffMaskAnalysis Plots and analysis using DiffMask of a BERT base model for sentiment analisys.
- ToyTask Training, analysis and plots for the artificial toy task using both other methods and DiffMask.
Please cite [1] in your work when using this library in your experiments.
For questions and comments, feel free to contact Nicola De Cao.
MIT
[1] De Cao, N., Schlichtkrull, M., Aziz, W., Titov, I. (2020).
How do Decisions Emerge across Layers in Neural Models?
Interpretation with Differentiable Masking
In Proceedings of the 2020 Conference on Empirical
Methods in Natural Language Processing.
BibTeX format:
@article{decao2020decisions,
title={How do Decisions Emerge across Layers in Neural Models?},
author={
De Cao, Nicola and
Aziz, Wilker and
Titov, Ivan},
journal={Proceedings of the 2020 Conference on Empirical
Methods in Natural Language Processing},
year={2020}
}