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")
sample_evaluations =  bench.evaluate_samples(hatexdata, [1,2])
bench.show_samples_evaluation_table(sample_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.3.0.tar.gz (44.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.3.0-py2.py3-none-any.whl (48.1 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: ferret-xai-0.3.0.tar.gz
  • Upload date:
  • Size: 44.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.3.0.tar.gz
Algorithm Hash digest
SHA256 3b1f6dcfd569c9fdb22da08dfb3ba50bb6bb5115cb1deb2b7aa8441c71f778b4
MD5 40c2a3634d7a21cc0ddccf94ead38ed0
BLAKE2b-256 e30188774a1a9e6826de75a189330e577ccd5852b9fa21ee99f3d1d5bffaa773

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ferret_xai-0.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 48.1 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.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 17fae4109ab3530b24b3aed20f5895512094b3f5091863d14b1ee2bbe0f2c836
MD5 748e17c76eb0db736921c4694136a6f5
BLAKE2b-256 24c1fc06e27bc4dbeb48fd0f1ffa94a977890e05f0039640a9ab0b142f5ba19d

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