Skip to main content

PolyAttention

Project description

Poly Attention (wip)

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)

Appreciation

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


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.1.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

poly_attention-0.1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: poly_attention-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for poly_attention-0.1.1.tar.gz
Algorithm Hash digest
SHA256 389992c9c0c63e672b19edfb2d1b376bff7b9e08688a2dcb0b5d9bb7ad049b56
MD5 5d24525b894bb41bc81612628847a241
BLAKE2b-256 cc3f8700133861253895ef0828a77fc3ddf826171bfcffeecdd73751d9d7dc16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for poly_attention-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fc77cfd8b82bd4ec6cb7706a996b5670649ce106a6dd866df69a01b388680ee5
MD5 27c9229b5cfe8d0160c35a09f3befc16
BLAKE2b-256 b5cc326df87865be7f662a545797d29e76df6934f75c4f4b11b850f6fada4d73

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