Skip to main content

Latest PyPI version Documentation Status

Ferret circular logo with the name to the right

A python package for benchmarking interpretability techniques.

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

bench = Benchmark(...)

explanations = ...
bench.show_table(explanations)

evaluations = bench.evaluate_explanations(explanations)
bench.show_evaluation_table(evaluations)

Datasets evaluations

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.

Logo and graphical assets made by Luca Attanasio.

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.0.tar.gz (43.7 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.0-py2.py3-none-any.whl (46.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ferret-xai-0.2.0.tar.gz.

File metadata

  • Download URL: ferret-xai-0.2.0.tar.gz
  • Upload date:
  • Size: 43.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.2 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.8.13

File hashes

Hashes for ferret-xai-0.2.0.tar.gz
Algorithm Hash digest
SHA256 68c8f49f0972658d0c726a806cb8a82127332a2aaf8145a7c237b4cda4e6faa4
MD5 9224cd85f41ba8d76bf36bcaef4f8540
BLAKE2b-256 22213cafdd2a8d57e3b98f736c7a2efe1679920a333c2bd25eeb0cba0e831132

See more details on using hashes here.

File details

Details for the file ferret_xai-0.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: ferret_xai-0.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 46.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.11.3 pkginfo/1.8.2 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.8.13

File hashes

Hashes for ferret_xai-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9931aac3d59282857f4b0d5a4c2642f687eabd7173e65f48ae22ad24fae686a9
MD5 cecb88664568f399f8b87f2dab49c852
BLAKE2b-256 1bfde343c32e919fb948445e06f48711b9cc0138b0cba76bd072f76d6ab5e3bc

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 Sentry Error logging StatusPage Status page