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.1.tar.gz (4.5 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.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: explainable_attention-0.0.1.tar.gz
  • Upload date:
  • Size: 4.5 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.1.tar.gz
Algorithm Hash digest
SHA256 7044734f72ca2a8964a7055945d074968e8c65c651274db5ae4b1b60cc3ceb68
MD5 70ecaaae8b2f6ec637997d51fa7436ad
BLAKE2b-256 0c8f73a08ad5a4e6a6a513248a5628535cfabcb4d3928afd87f8633a9f7798e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for explainable_attention-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 df30fafd7bc782b250c552739bde421a4e61d87cf415b0da21c5291de238839d
MD5 8e28f1434778b47db0318f69e11de2d4
BLAKE2b-256 e103936f715397eed16e0ad312bf3dcb26d36c91603599ebc94106bec31464ca

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