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 exact 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] Nicola De Cao, Michael Sejr Schlichtkrull, Wilker Aziz, and Ivan Titov. 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 (EMNLP),
pages 3243–3255, Online. Association for Computational Linguistics.
BibTeX format:
@inproceedings{de-cao-etal-2020-decisions,
title = "How do Decisions Emerge across Layers in Neural Models? Interpretation with Differentiable Masking",
author = "De Cao, Nicola and
Schlichtkrull, Michael Sejr and
Aziz, Wilker and
Titov, Ivan",
booktitle = "Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)",
month = nov,
year = "2020",
address = "Online",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2020.emnlp-main.262",
doi = "10.18653/v1/2020.emnlp-main.262",
pages = "3243--3255",
}