minGRU-pytorch


NameminGRU-pytorch JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryminGRU
upload_time2024-12-18 14:25:15
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2024 Phil Wang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords artificial intelligence associative scan based rnn deep learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## minGRU

Implementation of the proposed <a href="https://arxiv.org/abs/2410.01201v1">minGRU</a> in Pytorch, only the log-space numerically stable version.

<a href="https://www.youtube.com/watch?v=jE9jAZC42NE">Yannic's paper review</a>

## Install

```bash
$ pip install minGRU-pytorch
```

## Usage

```python
import torch
from minGRU_pytorch import minGRU

min_gru = minGRU(512)

x = torch.randn(2, 1024, 512)

out = min_gru(x)

assert x.shape == out.shape
```

Sanity check

```python
import torch
from minGRU_pytorch import minGRU

min_gru = minGRU(dim = 512, expansion_factor = 1.5)

x = torch.randn(1, 2048, 512)

# parallel

parallel_out = min_gru(x)[:, -1:]

# sequential

prev_hidden = None
for token in x.unbind(dim = 1):
    sequential_out, prev_hidden = min_gru(token[:, None, :], prev_hidden, return_next_prev_hidden = True)

assert torch.allclose(parallel_out, sequential_out, atol = 1e-4)
```

## Test

enwik8

```bash
$ python train.py
```

## Citations

```bibtex
@inproceedings{Feng2024WereRA,
    title   = {Were RNNs All We Needed?},
    author  = {Leo Feng and Frederick Tung and Mohamed Osama Ahmed and Yoshua Bengio and Hossein Hajimirsadegh},
    year    = {2024},
    url     = {https://api.semanticscholar.org/CorpusID:273025630}
}
```

```bibtex
@inproceedings{anonymous2024hymba,
    title   = {Hymba: A Hybrid-head Architecture for Small Language Models},
    author  = {Anonymous},
    booktitle = {Submitted to The Thirteenth International Conference on Learning Representations},
    year    = {2024},
    url     = {https://openreview.net/forum?id=A1ztozypga},
    note    = {under review}
}
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "minGRU-pytorch",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "artificial intelligence, associative scan based rnn, deep learning",
    "author": null,
    "author_email": "Phil Wang <lucidrains@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/83/99/958cf787f9ee128680a50119a901e85cd8e6511d369aa49f00f640015846/mingru_pytorch-0.1.1.tar.gz",
    "platform": null,
    "description": "## minGRU\n\nImplementation of the proposed <a href=\"https://arxiv.org/abs/2410.01201v1\">minGRU</a> in Pytorch, only the log-space numerically stable version.\n\n<a href=\"https://www.youtube.com/watch?v=jE9jAZC42NE\">Yannic's paper review</a>\n\n## Install\n\n```bash\n$ pip install minGRU-pytorch\n```\n\n## Usage\n\n```python\nimport torch\nfrom minGRU_pytorch import minGRU\n\nmin_gru = minGRU(512)\n\nx = torch.randn(2, 1024, 512)\n\nout = min_gru(x)\n\nassert x.shape == out.shape\n```\n\nSanity check\n\n```python\nimport torch\nfrom minGRU_pytorch import minGRU\n\nmin_gru = minGRU(dim = 512, expansion_factor = 1.5)\n\nx = torch.randn(1, 2048, 512)\n\n# parallel\n\nparallel_out = min_gru(x)[:, -1:]\n\n# sequential\n\nprev_hidden = None\nfor token in x.unbind(dim = 1):\n    sequential_out, prev_hidden = min_gru(token[:, None, :], prev_hidden, return_next_prev_hidden = True)\n\nassert torch.allclose(parallel_out, sequential_out, atol = 1e-4)\n```\n\n## Test\n\nenwik8\n\n```bash\n$ python train.py\n```\n\n## Citations\n\n```bibtex\n@inproceedings{Feng2024WereRA,\n    title   = {Were RNNs All We Needed?},\n    author  = {Leo Feng and Frederick Tung and Mohamed Osama Ahmed and Yoshua Bengio and Hossein Hajimirsadegh},\n    year    = {2024},\n    url     = {https://api.semanticscholar.org/CorpusID:273025630}\n}\n```\n\n```bibtex\n@inproceedings{anonymous2024hymba,\n    title   = {Hymba: A Hybrid-head Architecture for Small Language Models},\n    author  = {Anonymous},\n    booktitle = {Submitted to The Thirteenth International Conference on Learning Representations},\n    year    = {2024},\n    url     = {https://openreview.net/forum?id=A1ztozypga},\n    note    = {under review}\n}\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Phil Wang  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "minGRU",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://pypi.org/project/minGRU-pytorch/",
        "Repository": "https://github.com/lucidrains/minGRU-pytorch"
    },
    "split_keywords": [
        "artificial intelligence",
        " associative scan based rnn",
        " deep learning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6af56a332d44273d66b112b690567376e819df3ff35786bc770dcbeca02cfd7f",
                "md5": "a7f6d6f1950f4dad42edeb6b82cf9f90",
                "sha256": "c58ea0ca5804dabfdb74dff1f2d87003a9957da4d82194c7cca84763a2c0fe96"
            },
            "downloads": -1,
            "filename": "mingru_pytorch-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a7f6d6f1950f4dad42edeb6b82cf9f90",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 7750,
            "upload_time": "2024-12-18T14:25:11",
            "upload_time_iso_8601": "2024-12-18T14:25:11.056117Z",
            "url": "https://files.pythonhosted.org/packages/6a/f5/6a332d44273d66b112b690567376e819df3ff35786bc770dcbeca02cfd7f/mingru_pytorch-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8399958cf787f9ee128680a50119a901e85cd8e6511d369aa49f00f640015846",
                "md5": "d59eae3eedb06ef6f5171976da2c434c",
                "sha256": "b4d945d0cecc3d5f7c5a85a31ffe8c1ffceb4fc6ce1d5ace9b832c8d32d962da"
            },
            "downloads": -1,
            "filename": "mingru_pytorch-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d59eae3eedb06ef6f5171976da2c434c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 36568492,
            "upload_time": "2024-12-18T14:25:15",
            "upload_time_iso_8601": "2024-12-18T14:25:15.791349Z",
            "url": "https://files.pythonhosted.org/packages/83/99/958cf787f9ee128680a50119a901e85cd8e6511d369aa49f00f640015846/mingru_pytorch-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-18 14:25:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lucidrains",
    "github_project": "minGRU-pytorch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mingru-pytorch"
}
        
Elapsed time: 0.42522s