Skip to main content

Generalized Optimal Transport Attention with Trainable Priors (PyTorch).

Project description

GOAT Attention

PyPI Python License: MIT

Generalized Optimal Transport Attention with Trainable Priors (GOAT), available as a PyTorch multi-head attention module.

Install name: goat-attention (PyPI) · Import name: goat

GOAT Attention

Installation

  • From PyPI (recommended):
uv add goat-attention
  • pip:
pip install goat-attention
  • From source (editable):
uv pip install -e .
  • From source (editable, pip):
pip install -e .

Quickstart

import torch
from goat import GoatAttention

B, L, S, E, H = 2, 5, 7, 64, 8
xq = torch.randn(B, L, E)
xk = torch.randn(B, S, E)
xv = torch.randn(B, S, E)

attn = GoatAttention(
    embed_dim=E,
    num_heads=H,
    batch_first=True,
    pos_rank=2,
    abs_rank=4,
    enable_key_bias=True,
)

out, weights = attn(xq, xk, xv, is_causal=False, need_weights=True)
print(out.shape, None if weights is None else weights.shape)

CLI

After installation:

goat info
goat smoke

Documentation

See docs/:

Development

uv pip install -e ".[dev]"
pytest

License

MIT (see LICENSE).

Citation

If you find GOAT useful, please cite:

@misc{goat,
  title         = {You Need Better Attention Priors},
  author        = {Litman, Elon and ...},
  year          = {2026},
  eprint        = {XXXX.XXXXX},
  archivePrefix = {arXiv},
  primaryClass  = {cs.LG}
}

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

goat_attention-0.1.1.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

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

goat_attention-0.1.1-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file goat_attention-0.1.1.tar.gz.

File metadata

  • Download URL: goat_attention-0.1.1.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for goat_attention-0.1.1.tar.gz
Algorithm Hash digest
SHA256 60abac5eb5c799a4df264132ee0b320af6174a8b2fe88fde4b26104e8a6367cd
MD5 91c767a64937d825db5b9971bdbd0f14
BLAKE2b-256 983250b4452fea93799297f2d8b60709703122093307976b4b9363d73a5ac4d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for goat_attention-0.1.1.tar.gz:

Publisher: publish.yml on elonlit/goat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file goat_attention-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: goat_attention-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for goat_attention-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 61050720624be730be66cd38f7b77f4cac4780d53fcb8f5ccce45f01d53ecbfe
MD5 fcdd89fce42daefd1eb168d1c0f379d6
BLAKE2b-256 2bd45ab91520b4b4b186af2851e881066a5dfd04504fbd19fa1fae647c89f33b

See more details on using hashes here.

Provenance

The following attestation bundles were made for goat_attention-0.1.1-py3-none-any.whl:

Publisher: publish.yml on elonlit/goat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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