Name | improving-transformers-world-model JSON |
Version |
0.0.11
JSON |
| download |
home_page | None |
Summary | Improving Transformers World Model for RL |
upload_time | 2025-02-18 19:37:12 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT License
Copyright (c) 2025 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
deep learning
transformer
world model
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<img src="./fig1.png" width="450px"/>
<img src="./fig2.png" width="450px"/>
## Improving Transformers World Model - Pytorch (wip)
Implementation of the new SOTA for model based RL, from the paper [Improving Transformer World Models for Data-Efficient RL](https://arxiv.org/abs/2502.01591), in Pytorch.
They significantly outperformed DreamerV3 (as well as human experts) with a transformer world model and a less complicated setup, on Craftax (simplified Minecraft environment)
## Install
```bash
$ pip install improving-transformers-world-model
```
## Usage
```python
import torch
from improving_transformers_world_model import (
WorldModel
)
world_model = WorldModel(
image_size = 63,
patch_size = 7,
channels = 3,
transformer = dict(
dim = 512,
depth = 4,
block_size = 81
),
tokenizer = dict(
dim = 7 * 7 * 3,
distance_threshold = 0.5
)
)
state = torch.randn(2, 3, 20, 63, 63) # batch, channels, time, height, width - craftax is 3 channels 63x63, and they used rollout of 20 frames. block size is presumably each image
loss = world_model(state)
loss.backward()
# dream up a trajectory to be mixed with real for training PPO
prompts = state[:, :, :2] # prompt frames
imagined_trajectories = world_model.sample(prompts, time_steps = 20)
assert imagined_trajectories.shape == state.shape
```
## Citations
```bibtex
@inproceedings{Dedieu2025ImprovingTW,
title = {Improving Transformer World Models for Data-Efficient RL},
author = {Antoine Dedieu and Joseph Ortiz and Xinghua Lou and Carter Wendelken and Wolfgang Lehrach and J. Swaroop Guntupalli and Miguel L{\'a}zaro-Gredilla and Kevin Patrick Murphy},
year = {2025},
url = {https://api.semanticscholar.org/CorpusID:276107865}
}
```
Raw data
{
"_id": null,
"home_page": null,
"name": "improving-transformers-world-model",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "artificial intelligence, attention mechanism, deep learning, transformer, world model",
"author": null,
"author_email": "Phil Wang <lucidrains@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/fb/71/f180e43af910f0202038555f57fa725cb8d4a5aade9fc881fece7c300d67/improving_transformers_world_model-0.0.11.tar.gz",
"platform": null,
"description": "<img src=\"./fig1.png\" width=\"450px\"/>\n\n<img src=\"./fig2.png\" width=\"450px\"/>\n\n## Improving Transformers World Model - Pytorch (wip)\n\nImplementation of the new SOTA for model based RL, from the paper [Improving Transformer World Models for Data-Efficient RL](https://arxiv.org/abs/2502.01591), in Pytorch.\n\nThey significantly outperformed DreamerV3 (as well as human experts) with a transformer world model and a less complicated setup, on Craftax (simplified Minecraft environment)\n\n## Install\n\n```bash\n$ pip install improving-transformers-world-model\n```\n\n## Usage\n\n```python\nimport torch\n\nfrom improving_transformers_world_model import (\n WorldModel\n)\n\nworld_model = WorldModel(\n image_size = 63,\n patch_size = 7,\n channels = 3,\n transformer = dict(\n dim = 512,\n depth = 4,\n block_size = 81\n ),\n tokenizer = dict(\n dim = 7 * 7 * 3,\n distance_threshold = 0.5\n )\n)\n\nstate = torch.randn(2, 3, 20, 63, 63) # batch, channels, time, height, width - craftax is 3 channels 63x63, and they used rollout of 20 frames. block size is presumably each image\n\nloss = world_model(state)\nloss.backward()\n\n# dream up a trajectory to be mixed with real for training PPO\n\nprompts = state[:, :, :2] # prompt frames\n\nimagined_trajectories = world_model.sample(prompts, time_steps = 20)\n\nassert imagined_trajectories.shape == state.shape\n\n```\n\n## Citations\n\n```bibtex\n@inproceedings{Dedieu2025ImprovingTW,\n title = {Improving Transformer World Models for Data-Efficient RL},\n author = {Antoine Dedieu and Joseph Ortiz and Xinghua Lou and Carter Wendelken and Wolfgang Lehrach and J. Swaroop Guntupalli and Miguel L{\\'a}zaro-Gredilla and Kevin Patrick Murphy},\n year = {2025},\n url = {https://api.semanticscholar.org/CorpusID:276107865}\n}\n```\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2025 Phil Wang\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.",
"summary": "Improving Transformers World Model for RL",
"version": "0.0.11",
"project_urls": {
"Homepage": "https://pypi.org/project/improving-transformers-world-model-for-rl/",
"Repository": "https://github.com/lucidrains/improving-transformers-world-model-for-rl"
},
"split_keywords": [
"artificial intelligence",
" attention mechanism",
" deep learning",
" transformer",
" world model"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "0b4d0b9c6a20887b5fdc138e393a67ac543d1e2fed7e6ef3c0b7423b1ae86540",
"md5": "15928f4edb46f1d77aee39922ff5bfb8",
"sha256": "4c9efa449bc6a6ab0be6c2df8b2d5f630af34e4de35a1bf97607ceec56b30619"
},
"downloads": -1,
"filename": "improving_transformers_world_model-0.0.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "15928f4edb46f1d77aee39922ff5bfb8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 11391,
"upload_time": "2025-02-18T19:37:11",
"upload_time_iso_8601": "2025-02-18T19:37:11.303858Z",
"url": "https://files.pythonhosted.org/packages/0b/4d/0b9c6a20887b5fdc138e393a67ac543d1e2fed7e6ef3c0b7423b1ae86540/improving_transformers_world_model-0.0.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "fb71f180e43af910f0202038555f57fa725cb8d4a5aade9fc881fece7c300d67",
"md5": "5898fd3651dd2ed907795d0aa62b12e8",
"sha256": "52ac7b3d3b2cd5a471cb1cda95ad1d5eb76085f390667981311e003f1a402a36"
},
"downloads": -1,
"filename": "improving_transformers_world_model-0.0.11.tar.gz",
"has_sig": false,
"md5_digest": "5898fd3651dd2ed907795d0aa62b12e8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 599376,
"upload_time": "2025-02-18T19:37:12",
"upload_time_iso_8601": "2025-02-18T19:37:12.646798Z",
"url": "https://files.pythonhosted.org/packages/fb/71/f180e43af910f0202038555f57fa725cb8d4a5aade9fc881fece7c300d67/improving_transformers_world_model-0.0.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-18 19:37:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lucidrains",
"github_project": "improving-transformers-world-model-for-rl",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "improving-transformers-world-model"
}