Skip to main content

Monotonic attention implementation

Project description

monotonic-attention

Monotonic attention as a probabilistic graphical model

Write-up explaining how this works

Check out the examples/ directory for more information.

Getting Started

Install from PyPi:

pip install monotonic-attention

Install from source:

pip install git+https://github.com/codekansas/monotonic-attention.git

You should also install Triton if you plan to use the GPU kernels (highly recommended):

pip install triton

Usage

from monotonic_attention import OneToManyMultiheadMonotonicAttention

# Many keys mapped to a single query.
attn = OneToManyMultiheadMonotonicAttention(
  mode="many_keys_one_query",
  embed_dim=1024,
  num_heads=16,
)

output = attn(query, key, value)

# Many queries mapped to a single key.
attn = OneToManyMultiheadMonotonicAttention(
  mode="many_queries_one_key",
  embed_dim=1024,
  num_heads=16,
)

output = attn(query, key, value)

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

monotonic-attention-0.0.4.tar.gz (14.6 kB view hashes)

Uploaded Source

Built Distribution

monotonic_attention-0.0.4-py3-none-any.whl (17.8 kB view hashes)

Uploaded Python 3

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