ferret
========
|pypi badge| |docs badge|
|banner|
.. |pypi badge| image:: https://img.shields.io/pypi/v/ferret-xai.svg
:target: https://pypi.python.org/pypi/ferret-xai
:alt: Latest PyPI version
.. |Docs Badge| image:: https://readthedocs.org/projects/ferret/badge/?version=latest
:alt: Documentation Status
:scale: 100%
:target: https://ferret.readthedocs.io/en/latest/?version=latest
.. |banner| image:: ./images/banner.png
:alt: Ferret circular logo with the name to the right
:scale: 100%
A python package for benchmarking interpretability techniques.
* Free software: MIT license
* Documentation: https://ferret.readthedocs.io.
.. code-block:: python
from transformers import AutoModelForSequenceClassification, AutoTokenizer
from ferret import Benchmark
model = AutoModelForSequenceClassification.from_pretrained("bert-base-cased")
tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")
bench = Benchmark(model, tokenizer)
explanations = bench.explain("You look stunning!")
evaluations = bench.evaluate_explanations(explanations)
print(evaluations)
Features
--------
**ferret** builds on top of the transformers library. The library supports explanations using:
* Gradients
* Integrated Gradinets
* Gradient x Input word embeddings
* SHAP
* LIME
and evaluate explanations via:
Faithfulness measures.
* AOPC Comprehensiveness
* AOPC Sufficiency
* Kendall’s tau correlation with leave-one-feature out
Plausibility measures.
* AUPRC soft score plausibility
* Token f1 hard score plausibility
* Token IOU hard score plausibility
**TODOs**
* Possibility to run on select device ("cpu", "cuda")
* Sample-And-Occlusion explanations
* Discretized Integrated Gradients: https://arxiv.org/abs/2108.13654
Visualization
-------------
.. code-block:: python
bench = Benchmark(...)
explanations = ...
bench.show_table(explanations)
evaluations = bench.evaluate_explanations(explanations)
bench.show_evaluation_table(evaluations)
Datasets evaluations
--------------------
.. code-block:: python
bench = Benchmark(...)
hatexdata = bench.load_dataset("hatexplain")
dataset_explanations = bench.generate_dataset_explanations(hatexdata)
dataset_evaluations = bench.evaluate_dataset_explanations(dataset_explanations)
bench.show_dataset_evaluation_table(dataset_evaluations)
Credits
-------
This package was created with Cookiecutter and the *audreyr/cookiecutter-pypackage* project template.
- Cookiecutter: https://github.com/audreyr/cookiecutter
- `audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
Logo and graphical assets made by `Luca Attanasio <https://www.behance.net/attanasiol624d>`_.
=======
History
=======
0.1.0 (2022-05-30)
------------------
* First release on PyPI.
========
|pypi badge| |docs badge|
|banner|
.. |pypi badge| image:: https://img.shields.io/pypi/v/ferret-xai.svg
:target: https://pypi.python.org/pypi/ferret-xai
:alt: Latest PyPI version
.. |Docs Badge| image:: https://readthedocs.org/projects/ferret/badge/?version=latest
:alt: Documentation Status
:scale: 100%
:target: https://ferret.readthedocs.io/en/latest/?version=latest
.. |banner| image:: ./images/banner.png
:alt: Ferret circular logo with the name to the right
:scale: 100%
A python package for benchmarking interpretability techniques.
* Free software: MIT license
* Documentation: https://ferret.readthedocs.io.
.. code-block:: python
from transformers import AutoModelForSequenceClassification, AutoTokenizer
from ferret import Benchmark
model = AutoModelForSequenceClassification.from_pretrained("bert-base-cased")
tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")
bench = Benchmark(model, tokenizer)
explanations = bench.explain("You look stunning!")
evaluations = bench.evaluate_explanations(explanations)
print(evaluations)
Features
--------
**ferret** builds on top of the transformers library. The library supports explanations using:
* Gradients
* Integrated Gradinets
* Gradient x Input word embeddings
* SHAP
* LIME
and evaluate explanations via:
Faithfulness measures.
* AOPC Comprehensiveness
* AOPC Sufficiency
* Kendall’s tau correlation with leave-one-feature out
Plausibility measures.
* AUPRC soft score plausibility
* Token f1 hard score plausibility
* Token IOU hard score plausibility
**TODOs**
* Possibility to run on select device ("cpu", "cuda")
* Sample-And-Occlusion explanations
* Discretized Integrated Gradients: https://arxiv.org/abs/2108.13654
Visualization
-------------
.. code-block:: python
bench = Benchmark(...)
explanations = ...
bench.show_table(explanations)
evaluations = bench.evaluate_explanations(explanations)
bench.show_evaluation_table(evaluations)
Datasets evaluations
--------------------
.. code-block:: python
bench = Benchmark(...)
hatexdata = bench.load_dataset("hatexplain")
dataset_explanations = bench.generate_dataset_explanations(hatexdata)
dataset_evaluations = bench.evaluate_dataset_explanations(dataset_explanations)
bench.show_dataset_evaluation_table(dataset_evaluations)
Credits
-------
This package was created with Cookiecutter and the *audreyr/cookiecutter-pypackage* project template.
- Cookiecutter: https://github.com/audreyr/cookiecutter
- `audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
Logo and graphical assets made by `Luca Attanasio <https://www.behance.net/attanasiol624d>`_.
=======
History
=======
0.1.0 (2022-05-30)
------------------
* First release on PyPI.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ferret-xai-0.2.4.tar.gz
(43.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ferret-xai-0.2.4.tar.gz.
File metadata
- Download URL: ferret-xai-0.2.4.tar.gz
- Upload date:
- Size: 43.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3316fefe010b48bada3902e9768e3abd0a539564fa920886e9b1cd52fe6e88dc
|
|
| MD5 |
68e894e112d754e5d659727202ec147d
|
|
| BLAKE2b-256 |
bfee152f64bf6b64b0bc348e585afaba58237632464f57ffbcb2356b4b452edf
|
File details
Details for the file ferret_xai-0.2.4-py2.py3-none-any.whl.
File metadata
- Download URL: ferret_xai-0.2.4-py2.py3-none-any.whl
- Upload date:
- Size: 47.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea514ff7b647dafff42fa832d128b8f245686789dd5aee61b83ec5e7861176e9
|
|
| MD5 |
c395497132ffe1becca24b588311c367
|
|
| BLAKE2b-256 |
748c9e2175190726a6c998bcb24185b57ac3a01d13b8e8f6ae40561a67e52afd
|