Skip to main content

explainable-attention

Implementation of various tools for multi-head attention explainability from transformers.

Self-Attention Attribution

Hao, Yaru, et al. "Self-attention attribution: Interpreting information interactions inside transformer." Proceedings of the AAAI Conference on Artificial Intelligence. Vol. 35. No. 14. 2021.

from explainable_attention.self_attention_attribution import compute

...

def objective(batch):
    x, y = batch
    y = model(x)
    loss = loss_fn(x, y)
    return loss

attribution = saa.compute(
    model.transformer_encoder.layers,
    objective,
    batch,
    integration_steps=20)

Metadata

Release files for explainable-attention 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for explainable-attention 0.0.2
File Size Uploaded
explainable_attention-0.0.2.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for explainable-attention 0.0.2
File Interpreter ABI Platform
explainable_attention-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 kB

Release files / explainable_attention-0.0.2.tar.gz

Download URL explainable_attention-0.0.2.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
25320056a6bfa486a73575fb61e4d8cec3bfe5598605529dd54e9428196ab501
BLAKE2b-256 checksum
How to use checksums
8cd8b1a3c53f22250b2ce15e64a93f0245c5b7a47074da7545b0277277fadf8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / explainable_attention-0.0.2-py3-none-any.whl

Download URL explainable_attention-0.0.2-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88923d20e9891fd421a7dbee8924c77b1ec007889c2fba8aa6b4a4131d27a51f
BLAKE2b-256 checksum
How to use checksums
e14dae0b16c7c12a0e71962b4f7f3002262efda468d2fcc3160b8253a67bd252
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page