PolyAttention
Project description
Poly Attention
Implementation of Poly-Attention, a general scheme for higher-order self-attention
Install
$ pip install poly-attention
Usage
import torch
from poly_attention import PolyAttention
attn = PolyAttention(
dim = 512,
heads = 8,
dim_head = 64,
causal = False
)
tokens = torch.randn(1, 1024, 512)
out = attn(tokens) # (1, 1024, 512)
A Vision Transformer based on Poly-Attention
import torch
from poly_attention import PolyViT
vit = PolyViT(
image_size = 256,
patch_size = 32,
num_classes = 1000,
dim = 1024,
depth = 6,
heads = 16,
mlp_dim = 2048,
order = 2 # standard poly attention order 2
)
images = torch.randn(1, 3, 256, 256)
preds = vit(images) # (1, 1000)
Quick test
python train_function_composition.py --poly_layers=1 --base_layers=2
Appreciation
- @dillfrescott for submitting a stability fix
Citations
@inproceedings{chakrabarti2026poly,
title = {Poly-attention: a general scheme for higher-order self-attention},
author = {Chakrabarti, Sayak and Pitassi, Toniann and Alman, Josh},
booktitle = {International Conference on Learning Representations (ICLR)},
year = {2026}
}
@misc{kayyam2026transformersneedprojectionssystematic,
title = {Do Transformers Need Three Projections? Systematic Study of QKV Variants},
author = {Ali Kayyam and Anusha Madan Gopal and M Anthony Lewis},
year = {2026},
eprint = {2606.04032},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2606.04032},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
poly_attention-0.2.2.tar.gz
(11.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file poly_attention-0.2.2.tar.gz.
File metadata
- Download URL: poly_attention-0.2.2.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3cff8c30c35858f368d2f47e42179f0fadda677fa3962b6c0202597c2311cee
|
|
| MD5 |
79bc1c35cd5913b6b8e1811fcc3b4b1f
|
|
| BLAKE2b-256 |
e242fc6a7f1eae206d8763feb65f7639c2a854084683f398e85c5064d82b89a6
|
File details
Details for the file poly_attention-0.2.2-py3-none-any.whl.
File metadata
- Download URL: poly_attention-0.2.2-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
512d6915a142005e3d00ef784500d7f25547d94b88d487281726fc51b8950955
|
|
| MD5 |
6dd5ca6d6a1e6b20663783a4a142a9bc
|
|
| BLAKE2b-256 |
7c8f05e2c6c43c9e789d6c236e8dd2e4d810ba6a841bd95774ff18382e95881b
|