-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
# setfit-integrated-gradients | ||
|
||
Hacking SetFit so that it works with [integrated gradients](https://www.tensorflow.org/tutorials/interpretability/integrated_gradients). See demo.ipynb for an example. | ||
Hacking SetFit so that it works with [integrated gradients](https://www.tensorflow.org/tutorials/interpretability/integrated_gradients). See **demo.ipynb** for an example. | ||
|
||
I wrote this mini-library before SetFit 0.6.0. At the time, there was no SetFitHead class yet, so I just took the sklearn LogisticRegression and passed its parameters to an equivalent Torch class. I did my best to break the forward pass of SetFit into pieces so that I can push gradients through the head and up to the token embeddings. | ||
|
||
Attributions from integrated gradients are computed per token and then averaged to get word-level attributions. | ||
|
||
I'm leaving this here for posterity and in case it is useful to others for further hacking. | ||
Integrated gradients is a way to explain the decisions of the model by scoring what parts of the input influenced a particular decision. | ||
|
||
## Installation | ||
|
||
``` | ||
pip install -e . | ||
``` | ||
|
||
The "-e" switch installs the package in develop mode. | ||
|
||
## Notes | ||
|
||
I wrote this mini-library before SetFit 0.6.0. At the time, there was no SetFitHead class yet, so I just took the sklearn LogisticRegression and passed its parameters to an equivalent Torch class. I did my best to break the forward pass of SetFit into pieces so that I can push gradients through the head and up to the token embeddings. | ||
|
||
Attributions from integrated gradients are computed per token and then averaged to get word-level attributions. | ||
|
||
I'm leaving this here for posterity and in case it is useful to others for further hacking. |