Skip to main content
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.

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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ferret_xai-0.2.4-py2.py3-none-any.whl (47.0 kB view details)

Uploaded Python 2Python 3

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

Hashes for ferret-xai-0.2.4.tar.gz
Algorithm Hash digest
SHA256 3316fefe010b48bada3902e9768e3abd0a539564fa920886e9b1cd52fe6e88dc
MD5 68e894e112d754e5d659727202ec147d
BLAKE2b-256 bfee152f64bf6b64b0bc348e585afaba58237632464f57ffbcb2356b4b452edf

See more details on using hashes here.

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

Hashes for ferret_xai-0.2.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ea514ff7b647dafff42fa832d128b8f245686789dd5aee61b83ec5e7861176e9
MD5 c395497132ffe1becca24b588311c367
BLAKE2b-256 748c9e2175190726a6c998bcb24185b57ac3a01d13b8e8f6ae40561a67e52afd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page