world_model_data / README.md
joykirat's picture
Document both prediction targets in the dataset card
03118d9 verified
|
Raw History Blame Contribute Delete
12.9 kB
---
license: other
pretty_name: world_model_data (wm600)
tags:
- terminal-agent
- world-model
- agent-trajectories
configs: []
---
# world_model_data
Recorded terminal-agent trajectories paired with two prediction targets: the original
**abstracted observation**, and a newer **transition abstraction** that also states the
command's outcome, its effects on the machine, and the agent's workflow phase.
**Research artifact, not a released dataset.** Everything below is read off the files in this
repo and the run logs. Anything that was not recorded is marked as such rather than guessed at.
See **[`TARGETS.md`](TARGETS.md)** for the full description of both targets, the measured
differences between them, the reward that grades them, and the notes you need to consume this
corpus in another codebase.
## Purpose
To train and evaluate a **world model over a terminal**: given the conversation so far and the
command about to run, predict what will happen.
Raw terminal output is largely unpredictable — timestamps, inode numbers, process IDs, byte
counts, hashes. Asking a model to reproduce it verbatim trains it to guess noise, and scoring
against it punishes a correct understanding of the command. So every observation is rewritten
into its **predictable skeleton**: only what could have been derived before running the command,
from the transcript plus general knowledge of Linux.
## The two targets
**`abstraction_nl`** (2026-09-09, in `abstractions/`) — 1 to 4 sentences describing what the
terminal will print, restricted to what was predictable in advance.
**`paragraph`** (2026-09-13, in `enriched/`) — one paragraph of 3 to 6 sentences covering four
things in a fixed order: the outcome with its exit code and error class, the output as above,
the effects on the environment, and the workflow phase with the phase that follows and why.
The same step, both ways:
> **abstraction_nl** — The command attempts to extract the downloaded /tmp/vosk-model.zip with
> unzip and then list the resulting model directory. If unzip is not installed, it fails with
> "unzip: command not found" and exit code 127, and the subsequent ls commands never run;
> otherwise it would extract the model files and print the directory listing.
> **paragraph** — The command fails with exit code 127 because of a command not found. It prints
> only the shell's "unzip: command not found" line; the two listings never run. It changes the
> working directory to /tmp and makes no other change to the environment. This is an execute
> step; because the extraction tool is missing, the next step will be a repair that extracts the
> archive by another means.
The second target exists because the first describes only stdout. Across this corpus the older
target omits the failure on 23% of failed steps, omits any statement of success on 61% of
successful ones, never names 53% of the files that were created, modified or deleted, and has no
place at all for the 2,881 steps that start a background process, bind a port, install a package
or change the working directory. `TARGETS.md` has the full comparison.
Two things this corpus enables:
1. **Stage-1 training.** Supervise or RL a small model to predict a target. A model that can do
this has learned what commands do, not what strings appeared.
2. **A per-step difficulty signal.** Score how well a checkpoint predicts each step. Steps it
cannot predict are steps it does not understand, which correlates with downstream task failure
and is far cheaper than rolling out. Scores for the older target are published separately as
[`joykirat/wm_surprise_scores`](https://huggingface.co/datasets/joykirat/wm_surprise_scores).
## What is here
```
wm600/ main corpus, 600 tasks requested / 598 trajectories recorded
rollouts/ 598 JSONL, one per trajectory: the raw agent steps
abstractions/ 598 JSONL: abstraction_nl, the original target
phases/ 598 JSONL: StateM workflow phase per step
enriched/ 598 JSONL: paragraph + properties, the transition target
_report.md generation stats and failure breakdown
_review.md 40 steps, old target next to new
_judge_calibration*.md what the LLM judge does to deliberately broken answers
datasets/ training-ready parquet for the transition target
logs/
abstraction_review.md 30 sampled abstractions for manual review
smoke3/ 3-trajectory smoke corpus
```
Everything except `datasets/` is **generated** and expensive: 598 agent episodes of 27B
inference against live containers, 12,441 teacher calls to abstract their output, 598 more to
label phases, and 11,943 more to write the transition paragraphs. `datasets/` is a pure function
of the rest and is included only because it is what most consumers actually want; see
[Rebuilding](#rebuilding-the-training-data) to make it yourself.
## Scale
| | |
| --- | --- |
| trajectories | 598 |
| rows in `rollouts/` | 13,052 (598 are per-trajectory summary rows) |
| real agent steps | 12,454 |
| gold abstractions (`abstraction_nl`) | 12,441 (2 failed teacher calls) |
| phase labels | 12,454 (0 failed trajectories, 0.1% labelled `other`) |
| transition paragraphs (`paragraph`) | 11,740 usable of 11,943 requested |
| training rows exported | 10,846 train / 873 test |
## Row schemas
`rollouts/<task>.jsonl` — one row per agent step: `task_id`, `sample_idx`, `step_idx`,
`messages_before`, `action_command`, `raw_observation`, `observation`, `raw_exit_code`,
`assistant_message`, `image`, `model`, `reward`, `done`, `finish_reason`, `timing`, `ts`,
`usage`, `extra_backend_calls`. The final row of each file instead carries `final`, `num_steps`,
`done`, `reward`, `end_reason`.
`abstractions/<task>.jsonl` — `task_id`, `sample_idx`, `step_idx`, `abstraction_nl`,
`failed_nl`, `nl_len`, `raw_len`, `raw_capped`.
`phases/<task>.jsonl` — `task_id`, `sample_idx`, `step_idx`, `phase`, `phase_next`, `phase_why`,
`phase_source`, `activity`, `activity_next`, `outcome`, `end_reason`, `reward`, `num_steps`.
Phases are `plan`, `execute`, `verify`, `repair`, `handoff`, with `other` as an escape hatch.
`enriched/<task>.jsonl` — `task_id`, `sample_idx`, `step_idx`, `paragraph` (the target),
`properties` (structured view of the same facts, for metrics only), `facts` (the deterministic
inputs the annotator was given), `failed` (None when usable), `enrich_len`, `raw_capped`,
`model`.
Join any of them on `(task_id, sample_idx, step_idx)`. `task_id` is on the step rows as well as
the summary row, so the join needs no filename parsing.
## Training-ready export
`wm600/datasets/full/native/wm_rlvr_enriched_oi/{train,test}.parquet` — 10,846 / 873 rows, split
by task so no trajectory straddles the two. Columns: `messages` (the agent's conversation plus
the prediction query as the final user turn), `ground_truth` (the paragraph, a plain string),
`dataset`, `source`, `env_config`, `properties`. `properties.jsonl` beside them is keyed by
`sha1(ground_truth)` and carries both splits.
> **Read this before training on it.** The `dataset` column is stamped **`wm_rubric`**, which in
> a codebase that already has a verifier of that name will route these rows to *that* reward
> function, silently and with no error. `TARGETS.md` §5 measures what the older four-criterion
> judge does to these targets and tells you how to re-stamp the column.
A cosine-reward variant is one column away:
```python
import pyarrow.parquet as pq, pyarrow as pa
t = pq.read_table("train.parquet")
i = t.column_names.index("dataset")
pq.write_table(t.set_column(i, "dataset", pa.array(["wm_embed"] * t.num_rows)), "train_embed.parquet")
```
## Provenance
| | |
| --- | --- |
| acting / collection model | Qwen3.8-27B, bf16, tensor-parallel 4, served by vLLM |
| abstraction model | Qwen3.8-27B, bf16, same server, thinking on |
| phase + enrichment model | Qwen3.8-27B, bf16, same server; phases thinking on, enrichment thinking **off** |
| sampling | temperature 0.7 for collection, 0.0 for every annotation pass |
| task source | `allenai/tmax-15k-open-instruct`, snapshot `7b090eca98bf351356bc1c64290c5c4a09f2f98c`, tasks 0-599 at offset 0, 1 sample per task |
| container images | `hamishi740/swerl-tmax-v3:<per-task tag>` |
| sandbox backend | remote Docker broker, 2 CPU / 4 GiB per container |
| collected | 2026-09-09 |
| abstracted | 2026-09-09 to 2026-09-10 |
| phases + transition paragraphs | 2026-09-13 |
Because `task_id` matches the upstream tmax dataset, any row here can be traced back to its task
definition and verifier.
## Reproducing this repo from scratch
Needs the tmax project this was built in, a vLLM server for the 27B, and a Docker-capable
sandbox backend. Every stage is checkpointed and resumes if interrupted.
**1. Serve the teacher / actor.** One 27B behind an OpenAI-compatible endpoint. It needs a
tool-call parser, because collection drives a real agent:
```bash
vllm serve Qwen/Qwen3.8-27B \
--served-model-name Qwen3.8-27B --port 8100 \
--max-model-len 65536 --enable-prefix-caching \
--enable-auto-tool-choice --tool-call-parser qwen3_xml
export HOSTED_VLLM_API_BASE=http://127.0.0.1:8100/v1
```
**2. Collect trajectories** (the expensive stage: 600 episodes against live containers, ~6 h at
concurrency 12):
```bash
export LITELLM_EXTRA_BODY_JSON='{"chat_template_kwargs": {"enable_thinking": true}}'
python -m world_model.collect \
--parquet <tmax-15k snapshot>/data/train-00000-of-00001.parquet \
--task-data-dir <tmax-15k snapshot>/task-data.tar.gz.extracted \
--out-dir world_model_data/wm600 \
--num-tasks 600 --task-offset 0 --samples-per-task 1 \
--concurrency 12 --max-steps 64 \
--model hosted_vllm/Qwen3.8-27B --temperature 0.7 \
--context-budget 58000 --command-timeout 120 --mem-limit 4g \
--backend <docker|local_broker> --request-timeout 1800
```
**3. Abstract every observation** (12,441 teacher calls, ~5 h, thinking on):
```bash
python -m world_model.abstract \
--run-dir world_model_data/wm600 \
--style nl --model hosted_vllm/Qwen3.8-27B \
--concurrency 16 --max-raw-chars 60000 \
--chunk-size 256 --request-timeout 3600 --dump-review 30
```
**4. Label workflow phases** (598 trajectory-level calls, ~2.5 h, thinking on). One call per
trajectory, so the annotator sees the whole arc before deciding each step's phase:
```bash
python -m world_model.annotate_phases \
--run-dir world_model_data/wm600 --taxonomy statem \
--model hosted_vllm/Qwen3.8-27B --max-tokens 16384 \
--concurrency 8 --chunk-size 16
```
**5. Write the transition paragraphs** (11,943 calls, ~4 h, thinking **off**):
```bash
export LITELLM_EXTRA_BODY_JSON='{"chat_template_kwargs": {"enable_thinking": false}}'
python -m world_model.enrich \
--run-dir world_model_data/wm600 \
--model hosted_vllm/Qwen3.8-27B \
--concurrency 48 --chunk-size 256 --max-tokens 2048 \
--max-raw-chars 60000 --request-timeout 3600 --dump-review 40
```
Thinking is off here on purpose. With it on, the 27B spent its entire generation budget
reasoning toward a 130-token paragraph and truncated replies before the JSON. On 12 paired steps
it produced the same content either way. See `TARGETS.md` §7.
Exact reproduction is not expected. Agent rollouts are sampled at temperature 0.7, container
timing differs between hosts, and some commands are nondeterministic. Treat a re-collection as a
new corpus of the same kind.
## Rebuilding the training data
The parquet exports are a pure function of `rollouts/` + `abstractions/` + `phases/` +
`enriched/`:
```bash
# the transition target
python -m world_model.build_dataset \
--run-dir world_model_data/wm600 \
--emit-openinstruct --emit-openinstruct-enriched \
--oi-enriched-ablation-embed --oi-only-enriched \
--max-prompt-chars 100000 --eval-frac 0.1
# the original observation-only target
python -m world_model.build_dataset \
--run-dir world_model_data/wm600 \
--max-prompt-chars 100000 --steps-per-traj 10 --eval-frac 0.1
```
## Limitations
- Effects are **inferred** from the command and its output, not measured inside the container.
Validated against probe measurements on 31 steps: precision 0.94, recall 0.93. Blind spot:
effects only a script's execution reveals. `TARGETS.md` §4.
- The paragraph is templated by design, which makes it checkable but also makes its style
predictable; watch for a model learning form over content.
- References commit to the real outcome even where the transcript does not determine it.
- 158 steps were dropped for leaking the next command into the paragraph. Subtler hindsight is
not detectable by regex.
- Only 9.3% of steps failed, so rare error classes are thin: `permission` has 8 examples,
`syntax_error` 15.
- No downstream training result exists for the transition target yet.