Code-as-World README

The project's README from github.com/MirroS-Lab/Code-as-World. As one markdown file: README.md.

MirroS logo

Code-as-World

Agentic Discovery of Executable World Representations for Physical Reasoning

A world becomes intelligible to evolving intelligence when it can be represented, executed, and verified.

Paper Project Page Blog Code

Code-as-World overview

Overview

Pixels are evidence of the physical world, not its ontology. A pixel-level observation records how the world appears at a particular moment and from a particular viewpoint, but does not directly specify what exists within it, how it is structured, or what governs its evolution.

Code-as-World introduces code as executable representations for the physical world and an agentic process for discovering them through iterative simulation and verification. In doing so, it turns raw abundant observations into reusable physical data: explicit states, dynamics, and mechanisms that capture not only what was seen, but the underlying world that could have produced it. This provides scalable physical supervision, enabling our models to achieve state-of-the-art performance on quantitative physical reasoning.

News

Get started

The release includes local inference and QuantiPhy evaluation for Code-as-World-VL-4B and Code-as-World-VL-9B, plus a video-driven abstraction example.

Installation

Use Python 3.10 or 3.11 on a CUDA host.

git clone https://github.com/MirroS-Lab/Code-as-World.git
cd Code-as-World
python -m venv .venv
source .venv/bin/activate
pip install -r requirements/inference.txt

hf download MirroS-Lab/Code-as-World-VL-4B --local-dir weights/4b
hf download MirroS-Lab/Code-as-World-VL-9B --local-dir weights/9b

Clone QuantiPhy and download its validation videos:

git clone https://github.com/Paulineli/QuantiPhy.git /path/to/QuantiPhy
hf download PaulineLi/QuantiPhy-validation \
  --repo-type dataset \
  --local-dir /path/to/QuantiPhy-validation

QuantiPhy evaluation

Run the released evaluation directly from the Code-as-World repository:

python -m code_as_world.evaluation 4b \
  --input-csv /path/to/QuantiPhy/quantiphy_validation.csv \
  --video-dir /path/to/QuantiPhy-validation/validation_videos

python -m code_as_world.evaluation 9b \
  --input-csv /path/to/QuantiPhy/quantiphy_validation.csv \
  --video-dir /path/to/QuantiPhy-validation/validation_videos

Each run writes an evaluator-compatible prediction CSV, a single-run metric summary, and the raw generations to outputs/quantiphy/. To evaluate both CSV files with the official QuantiPhy evaluator:

pip install pandas
python /path/to/QuantiPhy/evaluator.py \
  outputs/quantiphy \
  outputs/quantiphy_metrics \
  --gt_file /path/to/QuantiPhy/quantiphy_validation.csv

OpenAI-compatible serving

The checkpoints can also be exposed through the standard vLLM API:

CUDA_VISIBLE_DEVICES=0 vllm serve weights/4b \
  --served-model-name code-as-world-4b \
  --chat-template code_as_world/templates/qwen3_5_no_think.jinja \
  --chat-template-content-format openai \
  --default-chat-template-kwargs '{"enable_thinking":false}' \
  --max-model-len 4608 \
  --gpu-memory-utilization 0.90 \
  --media-io-kwargs '{"video":{"num_frames":16,"fps":-1,"video_backend":"openpangu"}}' \
  --mm-processor-kwargs '{"do_sample_frames":false}' \
  --mm-processor-cache-gb 0 \
  --generation-config vllm

For the 9B checkpoint, replace weights/4b and code-as-world-4b with weights/9b and code-as-world-9b.

Video-driven abstraction example

Install MuJoCo and run the bundled ballistic soccer case:

pip install -r requirements/simulation.txt
python -m code_as_world.simulation

The rendered video and trajectory are written to outputs/simulations/. Use python -m code_as_world.simulation --no-render when only the trajectory is needed.

TODO

Acknowledgements

We sincerely thank the teams behind the following projects for making their work available to the community:

Component Projects
Physical simulation MuJoCo
Visual perception and reconstruction SAM 3, DA3, VGGT-Omega, SAM 3D
Realistic video generation Wan, VACE
Quantitative evaluation QuantiPhy

... and many other excellent open-source projects.

Citation

If you find Code-as-World useful, please cite:

@article{mirros2026codeasworld,
  title   = {Code as Worlds: Agentic Discovery of Executable World Representations for Physical Reasoning},
  author  = {{MirroS Team}},
  journal = {arXiv preprint arXiv:2608.27549},
  year    = {2026}
}

Code-as-World (MirroS-Lab/Code-as-World)

Searching Database…

这是什么?Code-as-World 是一个研究项目,把物理世界表示为可执行代码,通过仿真与验证的智能体循环来发现,让模型获得可复用的物理数据(状态、动力学、机制),而不只是原始像素。
这是训练好的模型,还是完整的研究流水线?它是一次完整的研究发布:两个预训练视觉语言检查点(4B 和 9B)、推理与评估代码,以及一个把视频片段转化为 MuJoCo 仿真的视频驱动抽象示例。
怎么让它跑起来?在配备 CUDA 的主机上使用 Python 3.10 或 3.11,然后克隆 QuantiPhy 基准仓库并下载其验证视频,之后再运行本仓库的评估或推理脚本。
除了 Python,运行这些检查点还需要什么?你需要一台配备 CUDA GPU 的主机、用于视频驱动仿真示例的 MuJoCo,以及 vLLM(如果你想通过它的 OpenAI 兼容 API 来服务 4B 或 9B 检查点)。
没有 GPU 能运行吗?不能,安装说明要求配备 CUDA 的主机,而且没有提到任何仅用 CPU 的推理或评估路径。
Code-as-World-VL-4B 和 9B 是什么?它们是已发布的两个视觉语言检查点,训练目标是产出物理场景的可执行代码表示,用于定量物理推理,可在本地运行或通过 vLLM 提供服务。
QuantiPhy 是什么?QuantiPhy 是该项目用来为定量物理推理的预测打分的官方基准和评估器,拥有自己的仓库和验证视频。
视频驱动抽象示例是做什么的?它使用 MuJoCo 把自带的弹道足球视频转化为可执行的仿真,把渲染出的视频和轨迹写入 outputs/simulations/(可通过 --no-render 使用仅轨迹模式)。
为什么使用代码而不是原始像素观测?作者认为像素只记录了场景的样子,而不是它的底层结构,因此用可执行代码来捕捉可能产生该观测结果的显式状态、动力学和机制。
Creator
MirroS-Lab
Size
11.3 MB
Stars
422
Updated
CommitAug 31
Age
1mo
Commits · 90 Days