Name | coconut-pytorch JSON |
Version |
0.0.23
JSON |
| download |
home_page | None |
Summary | Coconut in Pytorch |
upload_time | 2024-12-19 19:02:04 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
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. |
keywords |
artificial intelligence
attention mechanism
continuous latent tokens
deep learning
reasoning
transformers
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<img src="./coconut.png" width="400px"></img>
## 🥥 Coconut
Implementation of Coconut, proposed by the paper <a href="https://arxiv.org/abs/2412.06769">Training Large Language Models to Reason in a Continuous Latent Space</a> out of FAIR, in Pytorch
Architecture wise, the closest work to the one proposed here would be <a href="https://github.com/lucidrains/recurrent-memory-transformer-pytorch">RMT</a>, where the memory tokens there could serve as the continuous latent tokens. Both directions are worth exploring
## Install
```bash
$ pip install coconut-pytorch
```
## Usage
```python
import torch
from coconut_pytorch import Coconut
model = Coconut(
num_reasoning_steps = 3,
num_latents_per_step = 1,
transformer = dict(
num_tokens = 256,
dim = 512,
depth = 6
)
)
prompt = torch.randint(0, 256, (2, 1024))
answer = torch.randint(0, 256, (2, 64))
loss = model(prompt, answer)
loss.backward()
# after much training
answer = model.generate(prompt, max_length = 64) # (2, 64)
```
## Citation
```bibtex
@inproceedings{Hao2024TrainingLL,
title = {Training Large Language Models to Reason in a Continuous Latent Space},
author = {Shibo Hao and Sainbayar Sukhbaatar and DiJia Su and Xian Li and Zhiting Hu and Jason Weston and Yuandong Tian},
year = {2024},
url = {https://api.semanticscholar.org/CorpusID:274610816}
}
```
```bibtex
@article{Burtsev2021MultiStreamT,
title = {Multi-Stream Transformers},
author = {Mikhail S. Burtsev and Anna Rumshisky},
journal = {ArXiv},
year = {2021},
volume = {abs/2107.10342},
url = {https://api.semanticscholar.org/CorpusID:236171087}
}
```
Raw data
{
"_id": null,
"home_page": null,
"name": "coconut-pytorch",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "artificial intelligence, attention mechanism, continuous latent tokens, deep learning, reasoning, transformers",
"author": null,
"author_email": "Phil Wang <lucidrains@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/d3/92/4d1614035ce0626bbec13e40357177aa469eecb183755a30e5b60bc67597/coconut_pytorch-0.0.23.tar.gz",
"platform": null,
"description": "<img src=\"./coconut.png\" width=\"400px\"></img>\n\n## \ud83e\udd65 Coconut\n\nImplementation of Coconut, proposed by the paper <a href=\"https://arxiv.org/abs/2412.06769\">Training Large Language Models to Reason in a Continuous Latent Space</a> out of FAIR, in Pytorch\n\nArchitecture wise, the closest work to the one proposed here would be <a href=\"https://github.com/lucidrains/recurrent-memory-transformer-pytorch\">RMT</a>, where the memory tokens there could serve as the continuous latent tokens. Both directions are worth exploring\n\n## Install\n\n```bash\n$ pip install coconut-pytorch\n```\n\n## Usage\n\n```python\nimport torch\nfrom coconut_pytorch import Coconut\n\nmodel = Coconut(\n num_reasoning_steps = 3,\n num_latents_per_step = 1,\n transformer = dict(\n num_tokens = 256,\n dim = 512,\n depth = 6\n )\n)\n\nprompt = torch.randint(0, 256, (2, 1024))\nanswer = torch.randint(0, 256, (2, 64))\n\nloss = model(prompt, answer)\nloss.backward()\n\n# after much training\n\nanswer = model.generate(prompt, max_length = 64) # (2, 64)\n```\n\n## Citation\n\n```bibtex\n@inproceedings{Hao2024TrainingLL,\n title = {Training Large Language Models to Reason in a Continuous Latent Space},\n author = {Shibo Hao and Sainbayar Sukhbaatar and DiJia Su and Xian Li and Zhiting Hu and Jason Weston and Yuandong Tian},\n year = {2024},\n url = {https://api.semanticscholar.org/CorpusID:274610816}\n}\n```\n\n```bibtex\n@article{Burtsev2021MultiStreamT,\n title = {Multi-Stream Transformers},\n author = {Mikhail S. Burtsev and Anna Rumshisky},\n journal = {ArXiv},\n year = {2021},\n volume = {abs/2107.10342},\n url = {https://api.semanticscholar.org/CorpusID:236171087}\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": "Coconut in Pytorch",
"version": "0.0.23",
"project_urls": {
"Homepage": "https://pypi.org/project/coconut-pytorch/",
"Repository": "https://github.com/lucidrains/coconut-pytorch"
},
"split_keywords": [
"artificial intelligence",
" attention mechanism",
" continuous latent tokens",
" deep learning",
" reasoning",
" transformers"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6d7d440dd99fd7a8f48e15a5a6ab399bbc094a47cba88cf9019e74f8932945cc",
"md5": "ce5943189e58ad4540780aa3b1382484",
"sha256": "f9ed7b875c30cbe66bf20fd123da689897be8505e321a22b53113b3154fcce95"
},
"downloads": -1,
"filename": "coconut_pytorch-0.0.23-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ce5943189e58ad4540780aa3b1382484",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 12026,
"upload_time": "2024-12-19T19:02:02",
"upload_time_iso_8601": "2024-12-19T19:02:02.240620Z",
"url": "https://files.pythonhosted.org/packages/6d/7d/440dd99fd7a8f48e15a5a6ab399bbc094a47cba88cf9019e74f8932945cc/coconut_pytorch-0.0.23-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d3924d1614035ce0626bbec13e40357177aa469eecb183755a30e5b60bc67597",
"md5": "f973104fe6e8b9362ec597f12dc564b5",
"sha256": "8bf50c2d442b2fab14eaddd30bd16c7ecd368d36e1dd6c4bbda2e2a3e0093cfa"
},
"downloads": -1,
"filename": "coconut_pytorch-0.0.23.tar.gz",
"has_sig": false,
"md5_digest": "f973104fe6e8b9362ec597f12dc564b5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 130354,
"upload_time": "2024-12-19T19:02:04",
"upload_time_iso_8601": "2024-12-19T19:02:04.580862Z",
"url": "https://files.pythonhosted.org/packages/d3/92/4d1614035ce0626bbec13e40357177aa469eecb183755a30e5b60bc67597/coconut_pytorch-0.0.23.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-19 19:02:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lucidrains",
"github_project": "coconut-pytorch",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "coconut-pytorch"
}