| --- |
| license: cc-by-4.0 |
| viewer: false |
| tags: |
| - reinforcement-learning |
| - offline-reinforcement-learning |
| - unity-ml-agents |
| - minari |
| - causal-gpt-rl |
| --- |
| |
| # Causal GPT-RL — Unity ML-Agents trajectories |
|
|
| Recorded Unity ML-Agents trajectories packaged as |
| [Minari](https://minari.farama.org) datasets — **offline-RL datasets** spanning |
| continuous and discrete action spaces. Any offline-RL method can train on them; we |
| built them to develop **Causal GPT-RL**, our new approach that works across both |
| space types. Every environment |
| ships an `expert` tier; eight ship a full **quality ladder** (`expert` + |
| calibrated `medium`/`simple`) synthesized by degrading the stock policy — Gaussian |
| action-noise ranges for the continuous scenes, softmax-temperature ranges on the |
| policy logits for the discrete goal games. |
|
|
| Tiers are keyed to Minari-normalized skill between a random-policy `0.0` anchor |
| and the stock expert `1.0` — **targets `simple` 0.60 / `medium` 0.80 / `expert` |
| 1.0** (envs land at simple 0.59–0.61, medium 0.80–0.82). The degradation is not a |
| single constant: it is drawn **per episode from a calibrated range** (the group/team |
| scenes — DungeonEscape, SoccerTwos — draw per match instead), so each tier's *mean* |
| hits its target while the episodes span a continuous band of skill instead of piling |
| at one point. |
|
|
| **Companion repos** |
| - Model-removed Unity builds + matching stock ONNX policies: |
| [ccnets/causal-gpt-rl-unity-envs](https://huggingface.co/datasets/ccnets/causal-gpt-rl-unity-envs) |
| - Causal GPT-RL policy checkpoint (Pyramids): |
| [ccnets/causal-gpt-rl-unity](https://huggingface.co/ccnets/causal-gpt-rl-unity) |
|
|
| ## Data-quality notice — action labels (2026-07-30) |
|
|
| **All twelve datasets of the four discrete-action environments have been |
| re-recorded and replaced.** ML-Agents agents decide only every *k*-th physics |
| step and Unity repeats the last decision through the gap; the collector stored a |
| placeholder `0` for those in-between steps instead of the action Unity was |
| actually running. The action column therefore disagreed with the policy that |
| produced the trajectories — 72% of rows in the old PushBlock expert file. |
| **Observations, rewards, terminations and the trajectories themselves were never |
| affected**, so every published return, step-reward and tier calibration still |
| stands. |
|
|
| Share of rows that had held a placeholder action, measured per tier by replaying |
| the collector from the commit before the fix at each shipped band: |
|
|
| | env | affected rows | status | |
| |---|---:|---| |
| | `pushblock` | 47–72% | **all three tiers fixed** | |
| | `dungeon-escape` | 24–36% | **all three tiers fixed** | |
| | `soccer-twos` | ≈6% | **all three tiers fixed** | |
| | `pyramids` | 3–6% | **all three tiers fixed** | |
| | `crawler`, `walker`, `3dball-hard` | ≈1% | pending | |
| | `worm` | 0% | unaffected — decides every step | |
|
|
| The four continuous scenes above are still pending; `worm` never needed the fix. |
| If you consume observations/rewards only, every dataset here is usable as |
| published. If you need action labels — behavior cloning, action-conditioned |
| models, most offline RL — the discrete environments are now correct. |
|
|
| Because a collection run is not bit-reproducible (agents finish episodes |
| asynchronously, so the episode boundaries differ), the re-recorded tiers have |
| slightly different episode/transition counts and tier metrics than the files they |
| replaced — within ~1% and ~0.02 normalized respectively. The tables below carry |
| the new figures. |
|
|
| ## Contents |
|
|
| | Dataset id | Episodes | Transitions | Observation | Action | |
| |---|---:|---:|---|---| |
| | `unity/crawler/expert-v0` | 1,048 | 1,000,002 | `Tuple(Box(126), Box(32))` | `Box(20, [-1, 1])` | |
| | `unity/crawler/medium-v0` | 1,129 | 1,000,000 | `Tuple(Box(126), Box(32))` | `Box(20, [-1, 1])` | |
| | `unity/crawler/simple-v0` | 1,344 | 1,000,000 | `Tuple(Box(126), Box(32))` | `Box(20, [-1, 1])` | |
| | `unity/pushblock/expert-v0` | 53,039 | 1,000,000 | `Tuple(Box(105), Box(105))` | `Discrete(7)` | |
| | `unity/pushblock/medium-v0` | 39,033 | 1,010,016 | `Tuple(Box(105), Box(105))` | `Discrete(7)` | |
| | `unity/pushblock/simple-v0` | 26,666 | 1,010,016 | `Tuple(Box(105), Box(105))` | `Discrete(7)` | |
| | `unity/soccer-twos/expert-v0` | 14,692 | 1,001,676 | ego `Dict` wrapping `Tuple(Box(264), Box(72))` | ego `Dict` wrapping `MultiDiscrete([3, 3, 3])` | |
| | `unity/soccer-twos/medium-v0` | 12,940 | 1,002,368 | ego `Dict` wrapping `Tuple(Box(264), Box(72))` | ego `Dict` wrapping `MultiDiscrete([3, 3, 3])` | |
| | `unity/soccer-twos/simple-v0` | 11,820 | 1,001,564 | ego `Dict` wrapping `Tuple(Box(264), Box(72))` | ego `Dict` wrapping `MultiDiscrete([3, 3, 3])` | |
| | `unity/dungeon-escape/expert-v0` | 35,505 | 1,007,206 | ego `Dict` wrapping `Tuple(Box(10), Box(360), Box(1))` | ego `Dict` wrapping `Discrete(7)` | |
| | `unity/dungeon-escape/medium-v0` | 28,314 | 1,012,457 | ego `Dict` wrapping `Tuple(Box(10), Box(360), Box(1))` | ego `Dict` wrapping `Discrete(7)` | |
| | `unity/dungeon-escape/simple-v0` | 22,542 | 1,001,594 | ego `Dict` wrapping `Tuple(Box(10), Box(360), Box(1))` | ego `Dict` wrapping `Discrete(7)` | |
| | `unity/3dball-hard/expert-v0` | 1,009 | 1,000,008 | `Tuple(Box(27), Box(18))` | `Box(2)` | |
| | `unity/3dball-hard/medium-v0` | 1,250 | 1,000,008 | `Tuple(Box(27), Box(18))` | `Box(2)` | |
| | `unity/3dball-hard/simple-v0` | 1,655 | 1,000,008 | `Tuple(Box(27), Box(18))` | `Box(2)` | |
| | `unity/pyramids/expert-v0` | 5,392 | 1,000,000 | `Tuple(Box(56), Box(56), Box(56), Box(4))` | `Discrete(5)` | |
| | `unity/pyramids/medium-v0` | 4,174 | 1,000,000 | `Tuple(Box(56), Box(56), Box(56), Box(4))` | `Discrete(5)` | |
| | `unity/pyramids/simple-v0` | 3,065 | 1,000,000 | `Tuple(Box(56), Box(56), Box(56), Box(4))` | `Discrete(5)` | |
| | `unity/worm/expert-v0` | 1,000 | 1,000,000 | `Box(64)` | `Box(9, [-1, 1])` | |
| | `unity/worm/medium-v0` | 1,000 | 1,000,000 | `Box(64)` | `Box(9, [-1, 1])` | |
| | `unity/worm/simple-v0` | 1,000 | 1,000,000 | `Box(64)` | `Box(9, [-1, 1])` | |
| | `unity/walker/expert-v0` | 1,458 | 1,000,010 | `Box(243)` | `Box(39, [-1, 1])` | |
| | `unity/walker/medium-v0` | 1,712 | 1,000,000 | `Box(243)` | `Box(39, [-1, 1])` | |
| | `unity/walker/simple-v0` | 2,247 | 1,000,000 | `Box(243)` | `Box(39, [-1, 1])` | |
|
|
| All environments, datasets, and stock policies use **ML-Agents `release_23`**. |
| Each dataset is stored at `<name>/<tier>/data/main_data.hdf5` with a sibling |
| `metadata.json` (`minari_version` 0.5.3). SoccerTwos and DungeonEscape use an |
| ego-agent schema — `observations["agents"]["agent_0"]`, |
| `actions["agents"]["agent_0"]` — one ego episode per physical agent; split by |
| `match_id` (see [docs/reproduction.md](docs/reproduction.md)). |
| |
| ## Loading |
| |
| ```python |
| from pathlib import Path |
| from huggingface_hub import snapshot_download |
| import minari |
| |
| snapshot_download( |
| repo_id="ccnets/causal-gpt-rl-unity-datasets", |
| repo_type="dataset", |
| allow_patterns="worm/**", # one env; drop to fetch all |
| local_dir=Path.home() / ".minari" / "datasets" / "unity", |
| ) |
| dataset = minari.load_dataset("unity/worm/expert-v0") |
| # calibrated tiers: minari.load_dataset("unity/worm/medium-v0" | ".../simple-v0") |
| print(dataset.observation_space, dataset.action_space) |
| ``` |
| |
| ## Quality ladders |
|
|
| **Why these tiers look the way they do.** In a normal RL pipeline, `medium`/`simple` |
| data would come from *early training checkpoints* on the way to the expert. We don't |
| have those checkpoints — only the final expert policy — so each tier is **reduced |
| backward from the expert**: instead of one constant perturbation (a single degraded |
| point), every episode draws its skill from a calibrated *range*, so the tier |
| reproduces the *distribution* of skill a checkpoint spread would have. |
|
|
| Each ladder is a monotone skill sequence built from ONE stock policy: `expert` is |
| the unmodified policy, `medium`/`simple` degrade it progressively. The degradation |
| is calibrated so the tier mean hits its normalized target while episodes cover a |
| continuous skill band (seed 2310000): |
|
|
| - **continuous** scenes (crawler, worm, walker, 3dball-hard) add Gaussian action |
| noise, `noise_std` sampled per episode from a calibrated range; |
| - **discrete goal games** sample the policy's own action distribution via |
| `softmax(logits/T)` on the exposed discrete logits — higher `T` picks plausible |
| 2nd/3rd-best actions (smooth, in-distribution degradation, unlike epsilon-style |
| uniform-random swaps which are bimodal and off-distribution). PushBlock and |
| Pyramids each sample `T` **per episode** from a calibrated range (each episode |
| its own skill level, like a spread of early-training checkpoints); |
| - **cooperative** discrete DungeonEscape samples a softmax temperature `T` **per |
| group per match** from a calibrated range — all three agents in a group share one |
| `T`, so each match is one coherent skill level (like an early-training checkpoint); |
| competitive self-play SoccerTwos samples a softmax temperature `T` **per team per |
| match** from a (wider) calibrated range — the two teams draw independently, so each |
| match pairs two skill levels (a random gap, like cross-checkpoint league play). |
|
|
| Normalization is `(candidate − random) / (expert − random)` on each env's tier |
| metric. |
|
|
| | env | tier metric | medium | simple | noise method | |
| |---|---|---:|---:|---| |
| | `crawler` | episode return | 0.82 | 0.60 | per-episode `noise_std` range | |
| | `worm` | episode return | 0.80 | 0.60 | per-episode `noise_std` range | |
| | `walker` | episode return | 0.82 | 0.61 | per-episode `noise_std` range | |
| | `3dball-hard` | episode return | 0.80 | 0.60 | per-episode `noise_std` range | |
| | `pushblock` | step-reward | 0.80 | 0.60 | per-episode softmax temperature range | |
| | `pyramids` | step-reward | 0.79 | 0.60 | per-episode softmax temperature range | |
| | `dungeon-escape` | step-reward | 0.80 | 0.61 | per-group softmax temperature range | |
| | `soccer-twos` | match score | ≈0.80 | ≈0.60 | per-team softmax temperature range | |
|
|
| `soccer-twos` figures are approximate: self-play stays balanced, so tier skill |
| cannot be read off the shipped returns and comes from side-swapped calibration. |
| Sparse-reward scenes (pyramids, pushblock, dungeon, soccer) have a physically |
| bimodal per-episode outcome (solve vs. time-out), so the episode-return histogram |
| barely separates the tiers. For the goal games (`pushblock`, `pyramids`, `dungeon-escape`) the tier metric is |
| therefore **mean step-reward** = `return / episode length`, which grades *how |
| efficiently* the goal is reached — a continuous skill signal — normalized |
| `expert = 1 / random = 0` against the shipped `expert-v0` step-reward anchor |
| (pushblock 0.3537, pyramids 0.01263, dungeon-escape 0.01936). `simple` targets 0.60 |
| and the shipped tiers all sit at **0.60–0.61** (SoccerTwos, scored by side-swapped match |
| score rather than step-reward, is approximate); `medium` spans 0.79–0.82. |
|
|
| "termination rate" below = fraction of episodes ending on the env's terminal |
| condition — a fall for Crawler/Walker/3DBallHard, a solved push for PushBlock, |
| maze solve ("reach") for Pyramids; Worm never terminates (truncated at 1000). |
|
|
| <details> |
| <summary><b>Per-environment ladder tables</b> — exact ranges, anchors, mean returns, rates</summary> |
|
|
| **Crawler** — anchors: expert 2576.4899, random −0.88 |
|
|
| | tier | norm. return | noise_std range | mean return | term. rate | mean ep length | |
| |---|---:|---:|---:|---:|---:| |
| | `expert-v0` | 1.00 | -- | 2576.4899 | 0.077 | 954.20 | |
| | `medium-v0` | ≈0.82 | 0.15–0.23 | 2113.0960 | 0.209 | 885.74 | |
| | `simple-v0` | ≈0.60 | 0.21–0.32 | 1557.9818 | 0.460 | 744.05 | |
| |
| **Worm** — anchors: expert 1044.1063, random 0.80 (never terminates) |
| |
| | tier | norm. return | noise_std range | mean return | term. rate | mean ep length | |
| |---|---:|---:|---:|---:|---:| |
| | `expert-v0` | 1.00 | -- | 1044.1063 | 0.000 | 1000.00 | |
| | `medium-v0` | ≈0.80 | 0.09–0.15 | 839.4910 | 0.000 | 1000.00 | |
| | `simple-v0` | ≈0.60 | 0.15–0.22 | 632.4776 | 0.000 | 1000.00 | |
|
|
| **Walker** — anchors: expert 1363.6454, random −0.49 (high intrinsic return variance) |
|
|
| | tier | norm. return | noise_std range | mean return | term. rate | mean ep length | |
| |---|---:|---:|---:|---:|---:| |
| | `expert-v0` | 1.00 | -- | 1363.6454 | 0.512 | 685.88 | |
| | `medium-v0` | ≈0.82 | 0.05–0.11 | 1122.0456 | 0.652 | 584.11 | |
| | `simple-v0` | ≈0.61 | 0.09–0.15 | 835.2383 | 0.822 | 445.04 | |
| |
| **3DBallHard** — anchors: expert 99.1077, random 0.84 (capped balance: near-bimodal) |
| |
| | tier | norm. return | noise_std range | mean return | term. rate | mean ep length | |
| |---|---:|---:|---:|---:|---:| |
| | `expert-v0` | 1.00 | -- | 99.1077 | 0.001 | 991.09 | |
| | `medium-v0` | ≈0.80 | 0.28–0.38 | 79.6258 | 0.341 | 800.01 | |
| | `simple-v0` | ≈0.60 | 0.31–0.44 | 59.7502 | 0.612 | 604.23 | |
|
|
| **PushBlock** — tier metric is **mean step-reward** (`return / length`); step-reward anchors: expert 0.353699 (shipped `expert-v0`, 53,039 ep), random ≈−0.0005 (soft). Each tier samples `T` **per episode** from a calibrated range (each episode its own skill level, like a spread of early-training checkpoints). Higher `T` still solves but wanders more, so the return stays high (≈4.9) while step-reward falls with efficiency. term. rate = solved. |
|
|
| | tier | norm. step-reward | `T` (per episode) | mean step-reward | mean return | solved rate | mean ep length | |
| |---|---:|---:|---:|---:|---:|---:| |
| | `expert-v0` | 1.00 | -- | 0.353699 | 4.972780 | ≈1.00 | 18.85 | |
| | `medium-v0` | 0.80 | `U(2.1, 3.2)` | 0.282037 | 4.961591 | 0.997 | 25.88 | |
| | `simple-v0` | 0.60 | `U(3.25, 4.75)` | 0.213119 | 4.942463 | 0.996 | 37.88 | |
|
|
| **Pyramids** — tier metric is **mean step-reward** (`return / length`); step-reward anchors: expert 0.012633 (shipped `expert-v0`, 5,392 ep), random −0.001 (sparse: policy always times out at random). Each tier samples `T` **per episode** from a calibrated range (each episode its own skill level, like a spread of early-training checkpoints). Higher `T` reaches the goal less directly (longer episodes) so step-reward falls while return stays near expert. term. rate = mazes reached/solved. |
|
|
| | tier | norm. step-reward | `T` (per episode) | mean step-reward | mean return | reach rate | mean ep length | |
| |---|---:|---:|---:|---:|---:|---:| |
| | `expert-v0` | 1.00 | -- | 0.012633 | 1.797730 | 0.9911 | 185.46 | |
| | `medium-v0` | 0.79 | `U(2.7, 4.9)` | 0.009784 | 1.742249 | 0.990 | 239.58 | |
| | `simple-v0` | 0.60 | `U(4.8, 7.1)` | 0.007201 | 1.636223 | 0.981 | 326.26 | |
|
|
| **DungeonEscape** — cooperative goal game; tier metric is **mean step-reward** (`return / length`); step-reward anchors: expert 0.019355 (shipped `expert-v0`, 35,505 ego ep), random ≈0.00015. A softmax temperature `T` is sampled **per cooperative group per match** from a calibrated range and shared by all three agents (one coherent skill level per match, like an early-training checkpoint); higher `T` reaches the exit less efficiently so step-reward falls while the group still often succeeds. Group success `any(agent_return > 0)` (`group_metadata.jsonl`) therefore stays high across tiers and no longer separates them — step-reward does. |
|
|
| | tier | norm. step-reward | `T` range (per group) | mean step-reward | group success | mean ep length | |
| |---|---:|---|---:|---:|---:| |
| | `expert-v0` | 1.00 | stock (no noise) | 0.019355 | 0.9604 | 28.37 | |
| | `medium-v0` | 0.80 | `U(1.5, 3.0)` | 0.015446 | 0.9183 | 35.76 | |
| | `simple-v0` | 0.61 | `U(3.0, 4.0)` | 0.011950 | 0.8585 | 44.43 | |
|
|
| **SoccerTwos** — tier metric is **side-swapped match score** vs the fixed stock policy (self-play, so mean shipped return ≈ −0.04 for both tiers and does not track skill; figures are calibration estimates). Each **team** draws a softmax temperature `T` **independently per match** from a (wide) calibrated range on the exposed MultiDiscrete logits, shared by its two agents — so each match pairs two independently-drawn skill levels (a random gap = cross-checkpoint league play). A tier is set by the ego team's own drawn `T`; the norm is that band's mean side-swapped match score vs the fixed expert. term. rate = matches always terminate. |
|
|
| | tier | approx. norm. skill | `T` (per team/match) | matches | mean ep length | |
| |---|---:|---|---:|---:| |
| | `expert-v0` | 1.00 | stock (no noise) | 3,673 | 68.18 | |
| | `medium-v0` | ≈0.80 | `U(1.3, 2.6)` | 3,235 | 77.46 | |
| | `simple-v0` | ≈0.60 | `U(2.1, 3.4)` | 2,955 | 84.73 | |
|
|
| </details> |
|
|
| **Build & reproduction steps** (per-env recording recipe): see |
| [docs/reproduction.md](docs/reproduction.md). |
|
|
| ## Provenance & attribution |
|
|
| - Trajectories were generated by running Unity ML-Agents material (the builds and |
| stock policies are Apache-2.0; see the envs repo for provenance and licenses). |
| - The **trajectory data in this repo** is an original recording licensed |
| **CC-BY-4.0**. Please attribute *ccnets — Causal GPT-RL* and note the Unity |
| ML-Agents source environment. |
|
|
| ## License |
|
|
| Creative Commons Attribution 4.0 International (CC-BY-4.0). See `LICENSE`. |
|
|