{"id":19156226,"url":"https://github.com/kyegomez/differentialtransformer","last_synced_at":"2025-05-07T07:35:03.950Z","repository":{"id":257823890,"uuid":"871745235","full_name":"kyegomez/DifferentialTransformer","owner":"kyegomez","description":"An open source community implementation of the model from \"DIFFERENTIAL TRANSFORMER\" paper by Microsoft.","archived":false,"fork":false,"pushed_at":"2025-04-19T12:55:12.000Z","size":2265,"stargazers_count":24,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T20:16:52.669Z","etag":null,"topics":["ai","attention","ml","rnns","ssm","transformers","transformers-library","transformers-models"],"latest_commit_sha":null,"homepage":"https://discord.com/servers/agora-999382051935506503","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/kyegomez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"github":["kyegomez"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2024-10-12T20:16:59.000Z","updated_at":"2025-03-13T05:54:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"84f3a5bb-47d4-4747-a9a4-d2246a10e148","html_url":"https://github.com/kyegomez/DifferentialTransformer","commit_stats":null,"previous_names":["kyegomez/differentialtransformer"],"tags_count":0,"template":false,"template_full_name":"kyegomez/Python-Package-Template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FDifferentialTransformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FDifferentialTransformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FDifferentialTransformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kyegomez%2FDifferentialTransformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kyegomez","download_url":"https://codeload.github.com/kyegomez/DifferentialTransformer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252834188,"owners_count":21811333,"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":["ai","attention","ml","rnns","ssm","transformers","transformers-library","transformers-models"],"created_at":"2024-11-09T08:33:40.037Z","updated_at":"2025-05-07T07:35:03.922Z","avatar_url":"https://github.com/kyegomez.png","language":"Python","funding_links":["https://github.com/sponsors/kyegomez"],"categories":[],"sub_categories":[],"readme":"\n# Differential Transformer \n\nAn open source community implementation of the model from \"DIFFERENTIAL TRANSFORMER\" paper by Microsoft. [Paper Link](https://arxiv.org/abs/2410.05258). \"Differential attention takes the difference between two softmax attention functions to eliminate attention noise. The idea is analogous to differential amplifiers [19] proposed in electrical engineering,where the difference between two signals is used as output, so that we can null out the common-mode noise of the input. In addition, the design of noise-canceling headphones is based on a similar idea. We can directly reuse FlashAttention [8] as described in Appendix A, which significantly improves model efficiency.\"\n\n\n\n[![Join our Discord](https://img.shields.io/badge/Discord-Join%20our%20server-5865F2?style=for-the-badge\u0026logo=discord\u0026logoColor=white)](https://discord.gg/agora-999382051935506503) [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?style=for-the-badge\u0026logo=youtube\u0026logoColor=white)](https://www.youtube.com/@kyegomez3242) [![Connect on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white)](https://www.linkedin.com/in/kye-g-38759a207/) [![Follow on X.com](https://img.shields.io/badge/X.com-Follow-1DA1F2?style=for-the-badge\u0026logo=x\u0026logoColor=white)](https://x.com/kyegomezb)\n\n\n## Install\n\n```bash\n$ pip3 install differential-transformers\n```\n\n## Usage Transformer\n\n```python\n\nimport torch\nfrom differential_transformer.main import DifferentialTransformer\nfrom loguru import logger\n\n# Example usage:\n# Example dimensions\nbatch_size = 32\nseq_len = 128\nembedding_dim = 64\nh = 8\nλ = 0.1\nλinit = 0.05\n\n# Create random input tensor\nx = torch.randint(0, 256, (1, 1024))\n\n# Instantiate and run the multi-head attention\nmulti_head = DifferentialTransformer(heads=h, dim=embedding_dim, λinit=λinit)\noutput = multi_head(x, λ=λ)\n\nlogger.info(f\"Output shape: {output.shape}\")\n\n\n```\n\n# License\nMIT\n\n\n## Citation\n\n\n```bibtex\n@misc{ye2024differentialtransformer,\n    title={Differential Transformer}, \n    author={Tianzhu Ye and Li Dong and Yuqing Xia and Yutao Sun and Yi Zhu and Gao Huang and Furu Wei},\n    year={2024},\n    eprint={2410.05258},\n    archivePrefix={arXiv},\n    primaryClass={cs.CL},\n    url={https://arxiv.org/abs/2410.05258}, \n}\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyegomez%2Fdifferentialtransformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkyegomez%2Fdifferentialtransformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkyegomez%2Fdifferentialtransformer/lists"}