File size: 2,640 Bytes
84cabe2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
license: mit
task_categories:
  - text-generation
language:
  - en
tags:
  - maze
  - world-model
  - pathfinding
  - sequence-modeling
pretty_name: World Model for Maze (with X)
size_categories:
  - 1M<n<10M
---

# WorldModelForMazeWithX

Maze pathfinding sequences for training/probing sequence models (Transformer, Mamba, GRU, Gated-DeltaNet, ...). Task **C1**: relative-turn navigation on a fixed 10×10 directed grid. Includes a special **`x`** terminator marking wall-hit (illegal) paths, used to study a model's ability to recognize its own errors.

## Maze

- 10×10 grid, 100 nodes (`0``99`). Directed edges (down/right, both directions added), edge probability 0.6.
- Graph: `maze_graph_C1_RWs.graphml` (node ids are strings `'0'`..`'99'`).

## Sequence format (Task C1)

```
C <src> <tgt> : <turn tokens...>
```

- Agent starts facing **East**. Each turn token both rotates and advances one cell:
  - `F` forward, `L` left, `R` right, `T` turn-around.
- Nodes `0``99` are single tokens; `:` separates the prompt from the path.
- **`x`**: wall-hit terminator. A "wrong" path is a correct path with one turn corrupted into a wall direction, then `x` appended. Only the final `x` is supervised during training.

## Files (under `data/`)

| file | rows | wrong (`x`) ratio | note |
|------|------|-------------------|------|
| `train_C1_RWs_5M.txt` / `.bin`  | 5,000,000  | 0.0  | all-correct paths |
| `train_C1_RWs_8M.txt` / `.bin`  | 8,000,000  | 0.0  | all-correct paths |
| `train_C1_RWs_10M.txt` / `.bin` | 12,000,000 | 0.2  | 2M wall-hit paths ending in `x` |
| `test_C1_RWs_10K.txt`           | ~10K       | —    | held-out test prompts |
| `val_C1_RWs_10K.bin`            | —          | —    | tokenized validation |
| `meta_C1_RWs.pkl`              | —          | —    | vocab/stoi/itos (vocab size 132, `x` id 131) |
| `maze_graph_C1_RWs.graphml`    | —          | —    | the maze graph |

- `.txt`: human-readable sequences. `.bin`: `uint16` token stream (read with `numpy.memmap`). `.bin` can be regenerated from `.txt` via `prepare_multitask_minigpt.py`.
- Only the **10M** set contains wrong paths; 5M / 8M never expose `x` (models trained on them never emit `x`).

## Loading

```python
import pickle, numpy as np
meta = pickle.load(open("data/meta_C1_RWs.pkl", "rb"))
itos = meta["itos"]                       # x token id = 131
ids = np.memmap("data/train_C1_RWs_10M.bin", dtype=np.uint16, mode="r")
print(" ".join(itos[i] for i in ids[:60]))
```

## Citation

Generated with `data/maze/create_multitask_maze.py` (`--tasks C1 --path_type RWs`, `--wrong_ratio 0.2` for 10M, `0.0` for 5M/8M).