{"id":18764432,"url":"https://github.com/tripplyons/retentive-network","last_synced_at":"2025-10-04T02:26:24.606Z","repository":{"id":195441445,"uuid":"692894779","full_name":"tripplyons/retentive-network","owner":"tripplyons","description":"A minimal PyTorch implementation of Retentive Network","archived":false,"fork":false,"pushed_at":"2023-09-17T23:25:22.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-19T13:18:11.091Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/tripplyons.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}},"created_at":"2023-09-17T22:41:09.000Z","updated_at":"2023-09-17T23:27:38.000Z","dependencies_parsed_at":"2023-09-18T02:05:51.501Z","dependency_job_id":"86e6ec73-ae24-4c68-af1e-7c6134c16534","html_url":"https://github.com/tripplyons/retentive-network","commit_stats":null,"previous_names":["tripplyons/retentive-network"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tripplyons/retentive-network","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripplyons%2Fretentive-network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripplyons%2Fretentive-network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripplyons%2Fretentive-network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripplyons%2Fretentive-network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tripplyons","download_url":"https://codeload.github.com/tripplyons/retentive-network/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tripplyons%2Fretentive-network/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278254666,"owners_count":25956644,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2024-11-07T18:29:52.023Z","updated_at":"2025-10-04T02:26:24.591Z","avatar_url":"https://github.com/tripplyons.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Retentive Network (RetNet)\n\nA minimal PyTorch implementation of [Retentive Network: A Successor to Transformer for Large Language Models](https://arxiv.org/abs/2307.08621)\n\n## Notes\n\n- This repository exists mostly for educational purposes, for both me and anyone else who wants to learn about RetNet.\n- It is basically a direct translation of the math in the paper, complex numbers and all. I haven't looked into it, but there are other implementations that claim to do it without needing complex numbers.\n- It makes heavy use of `torch.einsum`, so make sure you understand it before trying to understand this code.\n- I haven't implemented the chunkwise recurrent mode yet, this repo only has the parallel and the recurrent modes.\n\n## Usage\n\nFor more examples see [test.py](test.py)\n\n```python\nimport torch\nfrom retnet import RetNet\n\nmodel = RetNet(256, 64, 4, 4)\n\nx = torch.randint(0, 256, (1, 64), dtype=torch.long)\n\nprint(model.loss(x))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftripplyons%2Fretentive-network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftripplyons%2Fretentive-network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftripplyons%2Fretentive-network/lists"}