# AI use cases for Code as World (MirroS-Lab/Code-as-World)

Repo: [MirroS-Lab/Code-as-World](https://github.com/MirroS-Lab/Code-as-World) | Use cases: 3 | Page: https://dedupedai.com/use-cases/mirros-lab-code-as-world/

Code-as-World is a Python research repo that provides local inference, QuantiPhy evaluation, OpenAI-compatible serving for its VL checkpoints, and a MuJoCo ballistic soccer example for physical reasoning.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Score Code as World checkpoints on QuantiPhy validation: https://dedupedai.com/use-cases/mirros-lab-code-as-world/evaluate-code-as-world-on-quantiphy/
- Serve a Code as World model behind an OpenAI-style API: https://dedupedai.com/use-cases/mirros-lab-code-as-world/serve-code-as-world-via-openai-api/
- Run the bundled ballistic soccer MuJoCo simulation: https://dedupedai.com/use-cases/mirros-lab-code-as-world/run-ballistic-soccer-physics-simulation/

## How to score Code as World checkpoints on QuantiPhy validation with Code as World

Repo: [MirroS-Lab/Code-as-World](https://github.com/MirroS-Lab/Code-as-World) | Difficulty: Advanced | Time: 2 hours | Basis: From the README

Run the released 4B or 9B model on QuantiPhy videos and get metrics from the official evaluator.

**Who it is for:** A researcher or ML engineer comparing physical reasoning models who needs reproducible QuantiPhy numbers for Code as World on a CUDA machine.

**The problem:** Reproducing a benchmark result means wiring together weights, the QuantiPhy dataset, and the official evaluator without a clear path.

**The outcome:** A prediction CSV, a metric summary, and raw generations in outputs/quantiphy/, plus official metrics in outputs/quantiphy_metrics.

### Steps

1. Clone the repo with `git clone https://github.com/MirroS-Lab/Code-as-World.git`, run `cd Code-as-World`, create a environment with `python -m venv .venv`, activate it with `source .venv/bin/activate`, and install with `pip install -r requirements/inference.txt`.
2. Download the 4B checkpoint with `hf download MirroS-Lab/Code-as-World-VL-4B --local-dir weights/4b`.
3. Clone the evaluator repo with `git clone https://github.com/Paulineli/QuantiPhy.git /path/to/QuantiPhy` and download the validation videos with `hf download PaulineLi/QuantiPhy-validation --repo-type dataset --local-dir /path/to/QuantiPhy-validation`. (inferred, check the README)
4. Run the evaluation with `python -m code_as_world.evaluation 4b --input-csv /path/to/QuantiPhy/quantiphy_validation.csv --video-dir /path/to/QuantiPhy-validation/validation_videos`. (inferred, check the README)
5. Install pandas with `pip install pandas`, then score the outputs with `python /path/to/QuantiPhy/evaluator.py outputs/quantiphy outputs/quantiphy_metrics --gt_file /path/to/QuantiPhy/quantiphy_validation.csv`. (inferred, check the README)

### Prompt to paste into your agent

```text
In the Code-as-World repo at <repo_path>, run `python -m code_as_world.evaluation 4b` against the QuantiPhy validation CSV at <csv_path> and videos at <video_dir>, then run the official QuantiPhy evaluator on outputs/quantiphy. Expect a prediction CSV, a metric summary, and an outputs/quantiphy_metrics result; verify that the prediction CSV row count matches the ground-truth CSV.
```

### Caveat

The README documents evaluation and inference only, so reported numbers depend on running the released checkpoints on the QuantiPhy validation set you download.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/mirros-lab-code-as-world/evaluate-code-as-world-on-quantiphy/

## How to serve a Code as World model behind an OpenAI-style API with Code as World

Repo: [MirroS-Lab/Code-as-World](https://github.com/MirroS-Lab/Code-as-World) | Difficulty: Advanced | Time: 1 hour | Basis: From the README

Expose the 4B or 9B checkpoint through vLLM so other tools can send video requests to it.

**Who it is for:** A developer building an app or agent workflow that needs a physical reasoning model reachable through a standard chat API on their own GPU.

**The problem:** Calling the checkpoints directly from custom Python code is awkward when the rest of the stack already speaks the OpenAI chat format.

**The outcome:** A running vLLM server that hosts code-as-world-4b (or code-as-world-9b) through the OpenAI-compatible API.

### Steps

1. Clone the repo with `git clone https://github.com/MirroS-Lab/Code-as-World.git`, run `cd Code-as-World`, create a environment with `python -m venv .venv`, activate it with `source .venv/bin/activate`, and run `pip install -r requirements/inference.txt`.
2. Download the checkpoint with `hf download MirroS-Lab/Code-as-World-VL-4B --local-dir weights/4b`.
3. Start the server with `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`, adding the remaining flags from the README's OpenAI-compatible serving block (including `--media-io-kwargs`, `--mm-processor-kwargs`, and `--generation-config vllm`). (inferred, check the README)
4. For the 9B checkpoint, swap `weights/4b` and `code-as-world-4b` for `weights/9b` and `code-as-world-9b`, and download it with `hf download MirroS-Lab/Code-as-World-VL-9B --local-dir weights/9b`.

### Prompt to paste into your agent

```text
In the Code-as-World repo at <repo_path>, start the vLLM server for weights/4b with the served model name code-as-world-4b using the flags in the README's OpenAI-compatible serving section. Then send one chat request containing <video_or_frames> and return the model's text reply. Verify that the server lists code-as-world-4b as an available model before sending the request.
```

### Caveat

The README gives the serve command for a CUDA host and a specific chat template, so the server will not run as documented on other setups.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/mirros-lab-code-as-world/serve-code-as-world-via-openai-api/

## How to run the bundled ballistic soccer MuJoCo simulation with Code as World

Repo: [MirroS-Lab/Code-as-World](https://github.com/MirroS-Lab/Code-as-World) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Render a soccer-kick trajectory from the video-driven abstraction example in a few commands.

**Who it is for:** A student or robotics or physics hobbyist who wants to see how Code as World turns a physical scene into an executable simulation.

**The problem:** It is hard to tell what an executable world representation looks like until you run one on a concrete physical case.

**The outcome:** A rendered video and trajectory file written to outputs/simulations/, or only the trajectory if you skip rendering.

### Steps

1. Clone the repo with `git clone https://github.com/MirroS-Lab/Code-as-World.git` and run `cd Code-as-World`.
2. Create an environment with `python -m venv .venv`, activate it with `source .venv/bin/activate`, and install the simulation requirements with `pip install -r requirements/simulation.txt`.
3. Run the bundled case with `python -m code_as_world.simulation`.
4. For a trajectory without rendering, run `python -m code_as_world.simulation --no-render`.

### Prompt to paste into your agent

```text
In the Code-as-World repo at <repo_path>, install requirements/simulation.txt and run `python -m code_as_world.simulation` to execute the bundled ballistic soccer case. Expect a rendered video and trajectory in outputs/simulations/; verify both files exist and that the trajectory file is non-empty.
```

### Caveat

The README only documents this one bundled soccer case, so it does not show how to build new executable world representations for other scenes.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/mirros-lab-code-as-world/run-ballistic-soccer-physics-simulation/
