SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.18499 · NeurIPS · 2023

Pre-training Contextualized World Models with In-the-wild Videos for Reinforcement Learning

Mingsheng Long, Haoyu Ma, Jialong Wu, Chaoyi Deng

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2305.18499.json · badge: /api/ran/2305.18499.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
thuml/ContextWM canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
FunctionStatusWhere it lives
count_episodes Ran
ran on a synthesized input
thuml/ContextWM/wmlib/core/replay.py
code served (permissive licence) · get_code("ed3c4acfebf1e198")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
from pathlib import Path
import os

# Create a temporary directory with mock .npz files
temp_dir = tempfile.mkdtemp()
directory = Path(temp_dir)

# Create mock .npz files with names that follow the pattern 'something-N.npz'
# where N is the number of steps + 1
# For example: 'episode-10.npz' means 10 - 1 = 9 steps
for i in range(3):
    filename = directory / f'episode-{10 + i}.npz"'
    # Create empty file to simulate .npz file
    filename.touch()

ARGS = {
    'directory': directory
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
dict_apply Ran
ran on a synthesized input
thuml/ContextWM/wmlib/core/torch_utils.py
code served (permissive licence) · get_code("0e570e9f59796944")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# The function dict_apply takes a dictionary d and applies function fn to each value
# It returns a new dictionary with the same keys but transformed values

# Create a simple test dictionary with various value types
test_dict = {
    'tensor': torch.randn(2, 4),
    'list': [1, 2, 3],
    'number': 42,
    'string': 'hello'
}

# Create a simple transformation function
def transform_fn(v):
    if isinstance(v, torch.Tensor):
        return v * 2
    elif isinstance(v, list):
        return [x * 2 for x in v]
    elif isinstance(v, (int, float)):
        return v * 2
    else:
        return v

ARGS = {
    'd': test_dict,
    'fn': transform_fn
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
dict_detach Ran
ran on a synthesized input
thuml/ContextWM/wmlib/core/torch_utils.py
code served (permissive licence) · get_code("adf5449f8b15f04e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function dict_detach expects a dictionary where values have a .detach() method
# This means the values should be torch tensors
d = {
    'tensor_a': torch.randn(2, 4),
    'tensor_b': torch.randn(3, 5),
    'tensor_c': torch.randn(2, 4, requires_grad=True),
}

ARGS = {'d': d}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
dict_to_device Ran
ran on a synthesized input
thuml/ContextWM/wmlib/core/torch_utils.py
code served (permissive licence) · get_code("6ba3e24b6a006d72")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function dict_to_device takes a dict and a device,
# and moves all tensor values to that device using .to(device)

# Create a small dict with tensor values
test_dict = {
    'tensor_1': torch.randn(2, 4),
    'tensor_2': torch.randn(3, 5),
    'nested': torch.randn(2, 2),
}

# Device to move tensors to (CPU)
device = 'cpu'

ARGS = {
    'd': test_dict,
    'device': device,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
lambda_return Ran
ran on a synthesized input
thuml/ContextWM/wmlib/core/other.py
code served (permissive licence) · get_code("26640a58b1b695f6")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (5, 2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
torch.manual_seed(0)

# Define arguments for lambda_return function
ARGS = {
    "reward": torch.randn(5, 2, 4),  # sequence length 5, batch 2, feature dim 4
    "value": torch.randn(5, 2, 4),   # same shape as reward
    "pcont": 0.99,                   # scalar discount factor
    "bootstrap": torch.randn(2, 4),  # batch 2, feature dim 4 (final value estimate)
    "lambda_": 0.95,                 # scalar lambda for GAE
    "axis": 0,                       # axis along which to scan (sequence dimension)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (5, 2, 4) — shape (5, 2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_episodes Ran
ran on a synthesized input
thuml/ContextWM/wmlib/core/replay.py
code served (permissive licence) · get_code("d4e79d3bcc3f8363")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
from pathlib import Path
import tempfile
import os

# Create a temporary directory with sample .npz files
temp_dir = tempfile.mkdtemp()
temp_path = Path(temp_dir)

# Create sample .npz files with episode data
# Format: filename should end with "-{length}.npz"
for i, length in enumerate([10, 15, 20]):
    episode_data = {
        'observations': np.random.randn(length, 4),
        'actions': np.random.randn(length, 2),
        'rewards': np.random.randn(length),
    }
    filename = temp_path / f'episode-{i}-{length}.npz'
    np.savez(filename, **episode_data)

ARGS = {
    'directory': temp_path,
    'capacity': None,
    'minlen': 1,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
save_episode Ran
ran on a synthesized input
thuml/ContextWM/wmlib/core/replay.py
code served (permissive licence) · get_code("1bf97c0a08cb2642")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned PosixPath. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import datetime
import io
import uuid
import numpy as np
from pathlib import Path
import tempfile

# Create a temporary directory for saving episodes
temp_dir = tempfile.TemporaryDirectory()
directory = Path(temp_dir.name)

# Create a minimal episode dict with the required structure
episode = {
    'image': np.random.randn(5, 64, 64, 3).astype(np.float32),  # 5 frames of 64x64 RGB images
    'action': np.random.randn(4, 2).astype(np.float32),  # 4 actions with 2 dimensions
    'reward': np.random.randn(4).astype(np.float32),  # 4 rewards
    'done': np.array([False, False, False, True], dtype=np.bool_),  # 4 done flags
}

ARGS = {
    'directory': directory,
    'episode': episode,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PosixPath — a PosixPath output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a PosixPath output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
schedule Not yet run
unverified (harvested, no recorded run)
thuml/ContextWM/wmlib/core/other.py
code served (permissive licence) · get_code("2e07fb68b4f246c1")
How it ran

no invocation recorded.

sequence_scan Not yet run
unverified (harvested, no recorded run)
thuml/ContextWM/wmlib/core/other.py
code served (permissive licence) · get_code("d7df2f57994415fa")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 9 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Unsupervised pre-training methods utilizing large and diverse datasets have achieved tremendous success across a range of domains. Recent work has investigated such unsupervised pre-training methods for model-based reinforcement learning (MBRL) but is limited to domain-specific or simulated data. In this paper, we study the problem of pre-training world models with abundant in-the-wild videos for efficient learning of downstream visual control tasks. However, inthe-wild videos are complicated with various contextual factors, such as intricate backgrounds and textured appearance, which precludes a world model from extracting shared world knowledge to generalize better. To tackle this issue, we introduce Contextualized World Models (ContextWM) that explicitly separate context and dynamics modeling to overcome the complexity and diversity of in-the-wild videos and facilitate knowledge transfer between distinct scenes. Specifically, a contextualized extension of the latent dynamics model is elaborately realized by incorporating a context encoder to retain contextual information and empower the image decoder, which encourages the latent dynamics model to concentrate on essential temporal variations. Our experiments show that in-the-wild video pre-training equipped with ContextWM can significantly improve the sample efficiency of MBRL in various domains, including robotic manipulation, locomotion, and autonomous driving.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2305.18499")
get_code_for_paper("2305.18499")
have("2305.18499")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2305.18499.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2305.18499.svg)](https://syntology.ai/paper/2305.18499)

Connect an agent — have() is free.