{"id":15601014,"url":"https://github.com/lucidrains/vn-transformer","last_synced_at":"2025-08-22T01:32:52.693Z","repository":{"id":55132522,"uuid":"502693268","full_name":"lucidrains/VN-transformer","owner":"lucidrains","description":"A Transformer made of Rotation-equivariant Attention using Vector Neurons","archived":false,"fork":false,"pushed_at":"2023-08-01T14:49:11.000Z","size":401,"stargazers_count":83,"open_issues_count":0,"forks_count":5,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-12-10T21:26:24.778Z","etag":null,"topics":["artificial-intelligence","attention-mechanism","deep-learning","geometric-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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-12T18:13:05.000Z","updated_at":"2024-10-26T10:47:50.000Z","dependencies_parsed_at":"2024-10-22T21:38:17.718Z","dependency_job_id":null,"html_url":"https://github.com/lucidrains/VN-transformer","commit_stats":{"total_commits":32,"total_committers":1,"mean_commits":32.0,"dds":0.0,"last_synced_commit":"f5704924405d2eb9593f7aa7c58f4e0c475d46d5"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2FVN-transformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2FVN-transformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2FVN-transformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucidrains%2FVN-transformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucidrains","download_url":"https://codeload.github.com/lucidrains/VN-transformer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229956891,"owners_count":18150861,"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","geometric-deep-learning","transformers"],"created_at":"2024-10-03T02:11:40.986Z","updated_at":"2024-12-20T07:07:17.887Z","avatar_url":"https://github.com/lucidrains.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./vn-transformer.png\" width=\"300px\"\u003e\u003c/img\u003e\n\n## VN (Vector Neuron) Transformer\n\nA \u003ca href=\"https://arxiv.org/abs/2206.04176\"\u003eTransformer made of Rotation-equivariant Attention\u003c/a\u003e using \u003ca href=\"https://arxiv.org/abs/2104.12229\"\u003eVector Neurons\u003c/a\u003e\n\n\u003ca href=\"https://openreview.net/forum?id=EiX2L4sDPG\"\u003eOpen Review\u003c/a\u003e\n\n## Appreciation\n\n- \u003ca href=\"https://stability.ai/\"\u003eStabilityAI\u003c/a\u003e for the generous sponsorship, as well as my other sponsors, for affording me the independence to open source artificial intelligence.\n\n## Install\n\n```bash\n$ pip install VN-transformer\n```\n\n## Usage\n\n```python\nimport torch\nfrom VN_transformer import VNTransformer\n\nmodel = VNTransformer(\n    dim = 64,\n    depth = 2,\n    dim_head = 64,\n    heads = 8,\n    dim_feat = 64,       # will default to early fusion, since this was the best performing\n    bias_epsilon = 1e-6  # in this paper, they propose breaking equivariance with a tiny bit of bias noise in the VN linear. they claim this leads to improved stability. setting this to 0 would turn off the epsilon approximate equivariance\n)\n\ncoors = torch.randn(1, 32, 3)    # (batch, sequence, spatial coordinates)\nfeats = torch.randn(1, 32, 64)\n\ncoors_out, feats_out = model(coors, feats = feats) # (1, 32, 3), (1, 32, 64)\n```\n\n## Tests\n\nConfidence in equivariance\n\n```bash\n$ python setup.py test\n```\n\n## Example\n\nFirst install `sidechainnet`\n\n```bash\n$ pip install sidechainnet\n```\n\nThen run the protein backbone denoising task\n\n```bash\n$ python denoise.py\n```\n\nIt does not perform as well as \u003ca href=\"https://github.com/lucidrains/En-transformer\"\u003eEn-Transformer\u003c/a\u003e, nor \u003ca href=\"https://github.com/lucidrains/equiformer-pytorch\"\u003eEquiformer\u003c/a\u003e\n\n## Citations\n\n```bibtex\n@inproceedings{Assaad2022VNTransformerRA,\n    title   = {VN-Transformer: Rotation-Equivariant Attention for Vector Neurons},\n    author  = {Serge Assaad and C. Downey and Rami Al-Rfou and Nigamaa Nayakanti and Benjamin Sapp},\n    year    = {2022}\n}\n```\n\n```bibtex\n@article{Deng2021VectorNA,\n    title   = {Vector Neurons: A General Framework for SO(3)-Equivariant Networks},\n    author  = {Congyue Deng and Or Litany and Yueqi Duan and Adrien Poulenard and Andrea Tagliasacchi and Leonidas J. Guibas},\n    journal = {2021 IEEE/CVF International Conference on Computer Vision (ICCV)},\n    year    = {2021},\n    pages   = {12180-12189},\n    url     = {https://api.semanticscholar.org/CorpusID:233394028}\n}\n```\n\n```bibtex\n@inproceedings{Kim2020TheLC,\n    title   = {The Lipschitz Constant of Self-Attention},\n    author  = {Hyunjik Kim and George Papamakarios and Andriy Mnih},\n    booktitle = {International Conference on Machine Learning},\n    year    = {2020},\n    url     = {https://api.semanticscholar.org/CorpusID:219530837}\n}\n```\n\n```bibtex\n@inproceedings{dao2022flashattention,\n    title   = {Flash{A}ttention: Fast and Memory-Efficient Exact Attention with {IO}-Awareness},\n    author  = {Dao, Tri and Fu, Daniel Y. and Ermon, Stefano and Rudra, Atri and R{\\'e}, Christopher},\n    booktitle = {Advances in Neural Information Processing Systems},\n    year    = {2022}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fvn-transformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucidrains%2Fvn-transformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucidrains%2Fvn-transformer/lists"}