Skip to main content

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

Project description

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)

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

explainable_attention-0.0.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

explainable_attention-0.0.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file explainable_attention-0.0.2.tar.gz.

File metadata

  • Download URL: explainable_attention-0.0.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for explainable_attention-0.0.2.tar.gz
Algorithm Hash digest
SHA256 25320056a6bfa486a73575fb61e4d8cec3bfe5598605529dd54e9428196ab501
MD5 62096d9ebf01500c3cabbd2aef1bf91a
BLAKE2b-256 8cd8b1a3c53f22250b2ce15e64a93f0245c5b7a47074da7545b0277277fadf8a

See more details on using hashes here.

File details

Details for the file explainable_attention-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for explainable_attention-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 88923d20e9891fd421a7dbee8924c77b1ec007889c2fba8aa6b4a4131d27a51f
MD5 d7b095063e6d0d2a32b28c8ebe6b0427
BLAKE2b-256 e14dae0b16c7c12a0e71962b4f7f3002262efda468d2fcc3160b8253a67bd252

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