Our code is implemented in PyTorch, using the Transformers libraries. Please make sure you have the latest version of these libraries installed.
Official code repository for the ICML'2022 paper:
"A Functional Information Perspective on Model Interpretation"
This work suggests a theoretical framework for model interpretability by measuring the contribution of relevant features to the functional entropy of the network with respect to the input. We rely on the log-Sobolev inequality that bounds the functional entropy by the functional Fisher information with respect to the covariance of the data.
The code was tested on a Conda environment installed on Ubuntu 18.04, with a python version of 3.9.
Please make sure you have the latest version of the following libraries installed:
Then, clone this repo to your local machine:
git clone https://github.com/nitaytech/FunctionalExplanation.git
Everything is ready, you can take a look at the demo notebook.
Basically, there are two main functions which generate the explanations:
fi_code.fi.explain()
and fi_code.fi.explain_batch()
, please take a look at their documentation.
In addition, we also support visualizing the explanations using: utils.show_explanations()
,
utils.show_explanations_grid()
and utils.textual_explanations_to_html()
.
Finally, we include a module fi_code.basic_models.py
which contains some helper functions for training toy models
(e.g. a ResNet-based CNN and Bi/LSTM, see the notebook for some examples).