Spaces:
Sleeping
Sleeping
File size: 5,188 Bytes
67acd34 | 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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
## Dataset Generation Pipeline
This repository includes a unified pipeline for generating ASCII puzzle datasets for training and evaluation. The pipeline generates puzzles, creates DataFrames with train/test splits, and can optionally upload to HuggingFace Hub.
### Quick Start
```bash
# Generate 100 samples of bridges puzzle (5x5, easy difficulty)
python run_ascii_puzzle_generation_pipeline.py --puzzles "bridges:5x5de" --n_samples 100
# Generate multiple puzzle configurations
python run_ascii_puzzle_generation_pipeline.py --puzzles "bridges:5x5de,bridges:7x7dm,loopy:5x5de" --n_samples 500
# Generate with a custom suffix and upload to HuggingFace
python run_ascii_puzzle_generation_pipeline.py --puzzles "bridges:5x5de" --suffix "grpo_train" --n_samples 1000
```
### Puzzle Configuration Format
Puzzles are specified using the format `puzzle_name:size_difficulty`:
| Component | Description | Examples |
|-----------|-------------|----------|
| `puzzle_name` | Name of the puzzle type | `bridges`, `galaxies`, `loopy`, `pattern`, `undead` |
| `size` | Grid dimensions | `5x5`, `7x7`, `10x10` |
| `difficulty` | Difficulty level suffix | `de` (easy), `dm` (medium), `dh` (hard) |
**Examples:**
- `bridges:5x5de` - 5x5 bridges puzzle, easy difficulty
- `galaxies:7x7dm` - 7x7 galaxies puzzle, medium difficulty
- `loopy:10x10dh` - 10x10 loopy puzzle, hard difficulty
### Available Puzzle Types and Difficulty Mappings
| Puzzle | Easy | Medium | Hard | Notes |
|--------|------|--------|------|-------|
| `bridges` | `d0` | `d1` | `d2` | Numeric difficulty |
| `galaxies` | `dn` (normal) | `du` (unreasonable) | `du` | Only 2 difficulty levels |
| `loopy` | `de` | `dt` (tricky) | `dh` | Uses square grid (`t0`) |
| `pattern` | N/A | N/A | N/A | No difficulty parameter |
| `undead` | `de` | `dn` (normal) | `dt` (tricky) | Grid sizes: 4x4, 5x5, 7x7 |
### Pipeline Arguments
```bash
python run_ascii_puzzle_generation_pipeline.py [OPTIONS]
```
| Argument | Description | Default |
|----------|-------------|---------|
| `--puzzles` | Comma-separated puzzle configs (required) | - |
| `--n_samples` | Number of samples per config | 1000 |
| `--n_workers` | Parallel workers for generation | 4 |
| `--output_dir` | Base output directory | `./pipeline_output` |
| `--suffix` | Suffix for dataset names | None |
| `--test_only` | Put all samples in test split | False |
| `--dedupe_test200` | Dedupe train against test200 datasets | False |
| `--skip_generation` | Skip puzzle generation step | False |
| `--skip_df` | Skip DataFrame creation step | False |
| `--skip_upload` | Skip HuggingFace upload step | False |
| `--run_folder` | Use existing run folder | None |
| `--hf_token` | HuggingFace authentication token | None |
| `--commit_message` | Commit message for HuggingFace | None |
### Output Structure
Each puzzle configuration gets its own timestamped folder:
```
pipeline_output/
├── bridges_5x5de_grpo_train_20251217_143052/
│ ├── txt/ # Generated puzzle files
│ │ ├── bridges_5x5de_abc123.txt
│ │ └── ...
│ └── csvs/ # CSV with train/test splits
│ └── bridges_5x5de_grpo_train_20251217_143052.csv
└── ...
```
### Common Use Cases
**Generate a test dataset (all samples in test split):**
```bash
python run_ascii_puzzle_generation_pipeline.py \
--puzzles "bridges:5x5de,bridges:7x7dm,bridges:10x10dh" \
--n_samples 200 \
--suffix "test200" \
--test_only
```
**Generate training data with deduplication:**
```bash
python run_ascii_puzzle_generation_pipeline.py \
--puzzles "bridges:5x5de" \
--n_samples 5000 \
--suffix "grpo_5k" \
--dedupe_test200 \
--n_workers 16
```
**Reuse existing puzzles (skip generation):**
```bash
python run_ascii_puzzle_generation_pipeline.py \
--puzzles "bridges:5x5de" \
--skip_generation \
--run_folder ./pipeline_output/bridges_5x5de_grpo_train_20251217_143052
```
### Pre-built Generation Scripts
The `scripts/` directory contains ready-to-use bash scripts for common dataset generation tasks:
| Script | Description |
|--------|-------------|
| `generate_all_rsft_1k.sh` | Generate all rsft_1k datasets (15k total) |
| `generate_bridges_rsft_1k.sh` | Bridges rsft_1k (3k samples) |
| `generate_bridges_grpo_5k.sh` | Bridges grpo_5k (30k samples) |
| `generate_*_test200.sh` | Test datasets (200 samples each) |
**Usage:**
```bash
# Generate only (no upload)
./scripts/generate_bridges_rsft_1k.sh
# Generate and upload to HuggingFace
./scripts/generate_bridges_rsft_1k.sh --upload
```
### Generated Puzzle File Format
Each generated `.txt` file contains:
```
Solved: True
Problem:
[ASCII representation of the initial puzzle state]
After move M1,0,3:
[ASCII state after move 1]
After move M2,1,4:
[ASCII state after move 2]
...
Final Solution:
[ASCII representation of the solved puzzle]
```
## License
The `RLP` code is released under the CC BY-NC 4.0 license. For more information, see [LICENSE](LICENSE).
Simon Tatham's Portable Puzzle Collection is licensed under the MIT License, see [puzzles/LICENCE](puzzles/LICENCE).
|