Skip to main content

Transformer eXplainability and eXploration

Project description

TX2

Code style: black PyPI version JOSS status tests

Welcome to TX2! This library is intended to aid in the explorability and explainability of transformer classification networks, or transformer language models with sequence classification heads. The basic function of this library is to take a trained transformer and test/train dataset and produce an ipywidget dashboard as seen in the screenshot below, which can be displayed in a jupyter notebook or jupyter lab.

screenshot

NOTE: Currently this library's implementation is partially torch-dependent, and so will not work with tensorflow/keras models - we hope to address this limitation in the future!

Installation

You can install this package from pypi:

pip install tx2

NOTE: depending on the environment, it may be better to install some of the dependencies separately before pip installing tx2, e.g. in conda:

conda install pytorch pandas scikit-learn=1.1 numpy=1.22 -c conda-forge

Examples

Example jupyter notebooks demonstrating and testing the usage of this library can be found in the examples folder.

Note that these notebooks can take a while to run the first time, especially if a GPU is not in use.

Packages you'll need to install for the notebooks to work (in addition to the conda installs above):

pip install tqdm transformers==4.21 datasets==2.4

Running through each full notebook will produce the ipywidget dashboard near the end.

The tests in this repository do not depend on transformers, so raw library functionality can be tested by running pytest in the project root.

Documentation

The documentation can be viewed at https://ornl.github.io/tx2/.

The documentation can also be built from scratch with sphinx as needed.

Install all required dependencies:

pip install -r requirements.txt

Build documentation:

cd docs
make html

The docs/build/html folder will now contain an index.html

Two notebooks demonstrating the dashboard and how to use TX2 are included in the examples folder, highlighting the default and custom approaches as discussed in the Basic Usage page of the documentation.

Citation

To cite usage of TX2 in a publication, the DOI for this code is https://doi.org/10.21105/joss.03652

bibtex:

@article{Martindale2021,
  doi = {10.21105/joss.03652},
  url = {https://doi.org/10.21105/joss.03652},
  year = {2021},
  publisher = {The Open Journal},
  volume = {6},
  number = {68},
  pages = {3652},
  author = {Nathan Martindale and Scott L. Stewart},
  title = {TX$^2$: Transformer eXplainability and eXploration},
  journal = {Journal of Open Source Software}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tx2-1.3.0.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

tx2-1.3.0-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

Details for the file tx2-1.3.0.tar.gz.

File metadata

  • Download URL: tx2-1.3.0.tar.gz
  • Upload date:
  • Size: 32.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for tx2-1.3.0.tar.gz
Algorithm Hash digest
SHA256 59b1442eef052a6fb3499d6dc3cb950bb1c274e7bf8bee23e1b65d380f5a91ef
MD5 fe84adef20e957037316124e1bbdbb80
BLAKE2b-256 57b59031ed1944601e7f463ab6cc28f5ad237d6a7cb43f84e7151e1c02bea0b9

See more details on using hashes here.

File details

Details for the file tx2-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: tx2-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for tx2-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c70b046219346f4b4cd5fced357e7ba30afaf400de22e3eed0633fe78cc98d0
MD5 14134fe43970d71564dc83830475fd13
BLAKE2b-256 ed409ccb952d0b78c94985a4f71fb39f08e13730ffdf23257d01a05096f72667

See more details on using hashes here.

Supported by

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