Metadata-Version: 2.4
Name: goat-attention
Version: 0.1.1
Summary: Generalized Optimal Transport Attention with Trainable Priors (PyTorch).
Author: Elon Litman
License: MIT License
        
        Copyright (c) 2026 GOAT Attention Contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
        
License-File: LICENSE
Keywords: alibi,attention,positional-encoding,pytorch,transformer
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: torch>=2.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
Requires-Dist: mkdocs>=1.5; extra == 'docs'
Description-Content-Type: text/markdown

## GOAT Attention

[![PyPI](https://img.shields.io/pypi/v/goat-attention.svg)](https://pypi.org/project/goat-attention/)
![Python](https://img.shields.io/pypi/pyversions/goat-attention.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

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

> **Install name:** `goat-attention` (PyPI) · **Import name:** `goat`

<p align="center">
  <img src="figs/goated.png" alt="GOAT Attention" width="320" />
</p>

## Installation

- **From PyPI (recommended)**:

```bash
uv add goat-attention
```

- **pip**:

```bash
pip install goat-attention
```

- **From source (editable)**:

```bash
uv pip install -e .
```

- **From source (editable, pip)**:

```bash
pip install -e .
```

## Quickstart

```python
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:

```bash
goat info
goat smoke
```

## Documentation

See `docs/`:

- [`docs/index.md`](docs/index.md)
- [`docs/usage.md`](docs/usage.md)
- [`docs/api.md`](docs/api.md)
- [`docs/development.md`](docs/development.md)

## Development

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

## License

MIT (see `LICENSE`).

## Citation

If you find GOAT useful, please cite:

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

