{"id":15600940,"url":"https://github.com/lucidrains/fast-transformer-pytorch","last_synced_at":"2025-04-13T09:36:33.823Z","repository":{"id":44759838,"uuid":"399136981","full_name":"lucidrains/fast-transformer-pytorch","owner":"lucidrains","description":"Implementation of Fast Transformer in Pytorch","archived":false,"fork":false,"pushed_at":"2021-08-26T14:18:34.000Z","size":65,"stargazers_count":173,"open_issues_count":0,"forks_count":16,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-27T01:09:38.327Z","etag":null,"topics":["artificial-intelligence","attention-mechanism","deep-learning","transformers"],"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/lucidrains.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-08-23T14:33:59.000Z","updated_at":"2025-03-05T15:13:58.000Z","dependencies_parsed_at":"2022-09-26T18:20:28.254Z","dependency_job_id":null,"html_url":"https://github.com/lucidrains/fast-transformer-pytorch","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Ffast-transformer-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Ffast-transformer-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Ffast-transformer-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2Ffast-transformer-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucidrains","download_url":"https://codeload.github.com/lucidrains/fast-transformer-pytorch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248691456,"owners_count":21146363,"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":["artificial-intelligence","attention-mechanism","deep-learning","transformers"],"created_at":"2024-10-03T02:09:51.613Z","updated_at":"2025-04-13T09:36:33.783Z","avatar_url":"https://github.com/lucidrains.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./fast-transformer.png\" width=\"400px\"\u003e\u003c/img\u003e\n\n## Fast Transformer - Pytorch\n\nImplementation of \u003ca href=\"https://arxiv.org/abs/2108.09084\"\u003eFast Transformer\u003c/a\u003e in Pytorch. This only work as an encoder.\n\n\u003ca href=\"https://www.youtube.com/watch?v=qgUegkefocg\"\u003eYannic video\u003c/a\u003e\n\n\u003ca href=\"https://www.youtube.com/watch?v=Ich5TIvdYRE\"\u003eAI Epiphany\u003c/a\u003e\n\n## Install\n\n```bash\n$ pip install fast-transformer-pytorch\n```\n\n## Usage\n\n```python\nimport torch\nfrom fast_transformer_pytorch import FastTransformer\n\nmodel = FastTransformer(\n    num_tokens = 20000,\n    dim = 512,\n    depth = 2,\n    max_seq_len = 4096,\n    absolute_pos_emb = True   # default uses relative positional encoding, but if that isn't working, then turn on absolute positional embedding by setting this to True\n)\n\nx = torch.randint(0, 20000, (1, 4096))\nmask = torch.ones(1, 4096).bool()\n\nlogits = model(x, mask = mask) # (1, 4096, 20000)\n```\n\n## Citations\n\n```bibtex\n@misc{wu2021fastformer,\n    title   = {Fastformer: Additive Attention is All You Need}, \n    author  = {Chuhan Wu and Fangzhao Wu and Tao Qi and Yongfeng Huang},\n    year    = {2021},\n    eprint  = {2108.09084},\n    archivePrefix = {arXiv},\n    primaryClass = {cs.CL}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Ffast-transformer-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucidrains%2Ffast-transformer-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Ffast-transformer-pytorch/lists"}