{"id":29023272,"url":"https://github.com/rish-16/aft-pytorch","last_synced_at":"2025-06-26T03:05:58.385Z","repository":{"id":49669255,"uuid":"372760559","full_name":"rish-16/aft-pytorch","owner":"rish-16","description":"Unofficial PyTorch implementation of Attention Free Transformer (AFT) layers by Apple Inc.","archived":false,"fork":false,"pushed_at":"2022-04-10T05:43:09.000Z","size":85,"stargazers_count":237,"open_issues_count":3,"forks_count":23,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-20T14:45:07.014Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rish-16.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-01T08:42:27.000Z","updated_at":"2025-05-20T09:25:53.000Z","dependencies_parsed_at":"2022-09-12T10:21:15.332Z","dependency_job_id":null,"html_url":"https://github.com/rish-16/aft-pytorch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rish-16/aft-pytorch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rish-16%2Faft-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rish-16%2Faft-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rish-16%2Faft-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rish-16%2Faft-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rish-16","download_url":"https://codeload.github.com/rish-16/aft-pytorch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rish-16%2Faft-pytorch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261217292,"owners_count":23126246,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-26T03:05:58.297Z","updated_at":"2025-06-26T03:05:58.366Z","avatar_url":"https://github.com/rish-16.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aft-pytorch\nUnofficial PyTorch implementation of **Attention Free Transformer**'s layers by [Zhai](https://twitter.com/zhaisf?lang=en), et al. [[abs](https://openreview.net/forum?id=pW--cu2FCHY), [pdf](https://arxiv.org/pdf/2105.14103.pdf)] from Apple Inc.\n\n\u003e I'd like to thank primary author, Dr. Shuangfei Zhai, for his informal guidance and feedback as I built this package! \n\n\u003cimg src=\"https://github.com/rish-16/aft-pytorch/raw/main/pic.png\" width=650\u003e\n\n## Installation\nYou can install `aft-pytorch` via `pip`:\n\n```bash\npip install aft-pytorch\n```\n\n## Usage\nYou can import the **AFT-Full** or **AFT-Simple** layer (as described in the paper) from the package like so:\n\n### `AFTFull`\n```python\nfrom aft_pytorch import AFTFull\n\nlayer = AFTFull(\n    max_seqlen=20,\n    dim=512,\n    hidden_dim=64\n)\n\n# a batch of sequences with 10 timesteps of length 512 each\nx = torch.rand(32, 10, 512)\ny = layer(x) # [32, 10, 512]\n```\n\n### `AFTSimple`\n```python\nfrom aft_pytorch import AFTSimple\n\nlayer = AFTSimple(\n    max_seqlen=20,\n    dim=512,\n    hidden_dim=64\n)\n\n# a batch of sequences with 10 timesteps of length 512 each\nx = torch.rand(32, 10, 512)\ny = layer(x) # [32, 10, 512]\n```\n### `AFTLocal`\n```python\nfrom aft_pytorch import AFTLocal\n\nlayer = AFTLocal(\n    max_seqlen=20,\n    dim=512,\n    hidden_dim=64\n)\n\n# a batch of sequences with 10 timesteps of length 512 each\nx = torch.rand(32, 10, 512)\ny = layer(x) # [32, 10, 512]\n```\n\n\u003e This layer wrapper is a 'plug-and-play' with your existing networks / Transformers. You can swap out the Self-Attention layer with the available layers in this package with minimal changes.\n\n## TODO\n- [ ] Add full AFT architecture\n- [ ] Add variants like, `AFTConv`\n- [ ] Benchmark using Karpathy's [minGPT](https://github.com/karpathy/minGPT)\n\n## Contributing\nIf you like this repo, please leave a star! If there are any amends or suggestions, feel free to raise a PR/issue.\n\n## Credits\n```\n@misc{attention-free-transformer,\ntitle = {An Attention Free Transformer},\nauthor = {Shuangfei Zhai and Walter Talbott and Nitish Srivastava and Chen Huang and Hanlin Goh and Ruixiang Zhang and Josh Susskind},\nyear = {2021},\nURL = {https://arxiv.org/pdf/2105.14103.pdf}\n}\n```\n\n## License\n[MIT](https://github.com/rish-16/aft-pytorch/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frish-16%2Faft-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frish-16%2Faft-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frish-16%2Faft-pytorch/lists"}