le-wm README

The project's README from github.com/lucas-maes/le-wm. As one markdown file: README.md.

LeWorldModel

Stable End-to-End Joint-Embedding Predictive Architecture from Pixels

Lucas Maes*, Quentin Le Lidec*, Damien Scieur, Yann LeCun and Randall Balestriero

Abstract: Joint Embedding Predictive Architectures (JEPAs) offer a compelling framework for learning world models in compact latent spaces, yet existing methods remain fragile, relying on complex multi-term losses, exponential moving averages, pretrained encoders, or auxiliary supervision to avoid representation collapse. In this work, we introduce LeWorldModel (LeWM), the first JEPA that trains stably end-to-end from raw pixels using only two loss terms: a next-embedding prediction loss and a regularizer enforcing Gaussian-distributed latent embeddings. This reduces tunable loss hyperparameters from six to one compared to the only existing end-to-end alternative. With ~15M parameters trainable on a single GPU in a few hours, LeWM plans up to 48× faster than foundation-model-based world models while remaining competitive across diverse 2D and 3D control tasks. Beyond control, we show that LeWM's latent space encodes meaningful physical structure through probing of physical quantities. Surprise evaluation confirms that the model reliably detects physically implausible events.

[ Paper | Checkpoints & Data | Website ]


If you find this code useful, please reference it in your paper:

@article{maes_lelidec2026lewm,
  title={LeWorldModel: Stable End-to-End Joint-Embedding Predictive Architecture from Pixels},
  author={Maes, Lucas and Le Lidec, Quentin and Scieur, Damien and LeCun, Yann and Balestriero, Randall},
  journal={arXiv preprint},
  year={2026}
}

Using the code

This codebase builds on stable-worldmodel for environment management, planning, and evaluation, and stable-pretraining for training. Together they reduce this repository to its core contribution: the model architecture and training objective.

Installation:

uv venv --python=3.10
source .venv/bin/activate
uv pip install stable-worldmodel[train,env]

Data

Datasets use the HDF5 format for fast loading. Download the data from HuggingFace and decompress with:

tar --zstd -xvf archive.tar.zst

Place the extracted .h5 files under $STABLEWM_HOME (defaults to ~/.stable-wm/). You can override this path:

export STABLEWM_HOME=/path/to/your/storage

Dataset names are specified without the .h5 extension. For example, config/train/data/pusht.yaml references pusht_expert_train, which resolves to $STABLEWM_HOME/pusht_expert_train.h5.

Training

jepa.py contains the PyTorch implementation of LeWM. Training is configured via Hydra config files under config/train/.

Before training, set your WandB entity and project in config/train/lewm.yaml:

wandb:
  config:
    entity: your_entity
    project: your_project

To launch training:

python train.py data=pusht

Checkpoints are saved to $STABLEWM_HOME upon completion.

For baseline scripts, see the stable-worldmodel scripts folder.

Planning

Evaluation configs live under config/eval/. Set the policy field to the checkpoint path relative to $STABLEWM_HOME, without the _object.ckpt suffix:

# ✓ correct
python eval.py --config-name=pusht.yaml policy=pusht/lewm

# ✗ incorrect
python eval.py --config-name=pusht.yaml policy=pusht/lewm_object.ckpt

Pretrained Checkpoints

Pretrained LeWM checkpoints for each environment are mirrored on the Hugging Face Hub (model repos), alongside the datasets (dataset repos) in the same collection:

The full baseline checkpoint suite (PLDM, LeJEPA, IVL, IQL, GCBC, DINO-WM, DINO-WM-noprop) is available on Google Drive:

Method two-room pusht cube reacher
pldm ✓ ✓ ✓ ✓
lejepa ✓ ✓ ✓ ✓
ivl ✓ ✓ ✓ —
iql ✓ ✓ ✓ —
gcbc ✓ ✓ ✓ —
dinowm ✓ ✓ — —
dinowm_noprop ✓ ✓ ✓ ✓

Loading a checkpoint

From the Drive archive

Each tar archive contains two files per checkpoint:

Place the extracted files under $STABLEWM_HOME/ and load via:

import stable_worldmodel as swm

# Load the cost model (for MPC)
cost = swm.policy.AutoCostModel('pusht/lewm')

AutoCostModel accepts:

The returned module is in eval mode with its PyTorch weights accessible via .state_dict().

From the Hugging Face mirror

The HF model repos ship the LeWM checkpoint as a weights.pt (state dict) plus a config.json describing the model. Convert once to produce the _object.ckpt that eval.py expects:

# download weights.pt + config.json
hf download quentinll/lewm-pusht --local-dir $STABLEWM_HOME/hf_pusht

# convert to object checkpoint under $STABLEWM_HOME/pusht/lewm_object.ckpt
python - <<'PY'
import json, torch, stable_pretraining as spt
from pathlib import Path
from jepa import JEPA
from module import ARPredictor, Embedder, MLP
import stable_worldmodel as swm

src = Path(swm.data.utils.get_cache_dir(), "hf_pusht")
out = Path(swm.data.utils.get_cache_dir(), "pusht", "lewm_object.ckpt")

cfg = json.loads((src / "config.json").read_text())
encoder = spt.backbone.utils.vit_hf(
    cfg["encoder"]["size"],
    patch_size=cfg["encoder"]["patch_size"],
    image_size=cfg["encoder"]["image_size"],
    pretrained=False, use_mask_token=False,
)
mlp = lambda k: MLP(input_dim=cfg[k]["input_dim"], output_dim=cfg[k]["output_dim"],
                    hidden_dim=cfg[k]["hidden_dim"], norm_fn=torch.nn.BatchNorm1d)
model = JEPA(
    encoder=encoder,
    predictor=ARPredictor(**cfg["predictor"]),
    action_encoder=Embedder(**cfg["action_encoder"]),
    projector=mlp("projector"),
    pred_proj=mlp("pred_proj"),
)
sd = torch.load(src / "weights.pt", map_location="cpu", weights_only=False)
model.load_state_dict(sd, strict=True)
out.parent.mkdir(parents=True, exist_ok=True)
torch.save(model, out)
PY

After conversion, load via swm.policy.AutoCostModel('pusht/lewm') as usual.

Contact & Contributions

Feel free to open issues! For questions or collaborations, please contact [email protected]

le-wm (lucas-maes/le-wm)

Searching Database…

4.5K ·GitHub
这是什么?这是 LeWorldModel(LeWM)的官方代码库。它是一种联合嵌入预测架构(JEPA),仅用两个损失项就能直接从像素学习世界模型,避开了 EMA、预训练编码器或辅助监督等常见技巧。
这是一个独立的库,还是依赖其他仓库?它是一个研究代码库,依赖两个配套包:stable-worldmodel 负责环境、规划和评估,stable-pretraining 负责训练,这个仓库则专注于 jepa.py(模型架构和训练目标)。
怎么训练一个 LeWM 模型?训练由 config/train/ 下的 Hydra 配置文件驱动(在 config/train/lewm.yaml 中设置你的 WandB entity/project,然后启动训练);完成后检查点会保存到 $STABLEWMHOME。
训练数据集从哪里来?数据集以 HDF5 文件的形式发布在 HuggingFace 上;你下载并解压后,把 .h5 文件放到 $STABLEWMHOME 目录下(默认为 ~/.stable-wm/)。
一切都必须从头训练吗?不必——pusht、cube、two-room 和 reacher 环境的预训练 LeWM 检查点已镜像到 Hugging Face Hub,更全面的基线套件(PLDM、LeJEPA、IVL、IQL、GCBC、DINO-WM)可通过 Google Drive 获取。
使用它需要大型 GPU 集群吗?不需要——LeWM 只有约 15M 参数,在单张 GPU 上几小时即可完成训练,而且其规划速度最高可达基于基础模型的世界模型的 48 倍。
LeWM 在哪些任务上测试过?论文在多样的 2D 和 3D 控制任务上对它进行了评估,包括 pusht、cube、two-room 和 reacher 环境,这些环境也提供了预训练检查点和基线。
LeWM 与其他基于 JEPA 的世界模型有何不同?与唯一的另一个端到端 JEPA 方案相比,LeWM 把可调的损失超参数从六个削减到一个,因为它只需一个下一嵌入预测损失加一个高斯正则项就能避免表征坍缩。
这个模型学到的不仅仅是控制策略吗?是的——对潜在空间的探测显示它编码了有意义的物理量,一项惊喜度评估测试也显示模型能可靠地标记出物理上不合理的事件。
怎么加载预训练检查点?检查点包含一个 object.ckpt(eval.py 使用的序列化 Python 对象)和一个 weight.ckpt(状态字典);如果来自 Hugging Face 镜像,需要先把手头的 weights.pt/config.json 转换成 object.ckpt,再通过 swm.policy.AutoCostModel 加载。
Creator
lucas-maes
Size
5.3 MB
Stars
4.5K
Updated
CommitMay 22
Age
7mo
Commits · 90 Days