Spaces:
Sleeping
Sleeping
File size: 2,408 Bytes
2058884 | 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 | """
Curriculum dataset builder for GRPO training.
Converts TASK_REGISTRY into a HuggingFace Dataset ordered by difficulty
(easy β medium β hard). Each row is one prompt the model will be asked to complete.
Easy tasks are repeated more often so the model builds base competence first
(from Daniel's GPU Mode talk: "probability of good answer must be > 0").
"""
from datasets import Dataset
from debug_env.server.tasks.data import TASK_REGISTRY
DIFFICULTY_ORDER = {"easy": 0, "medium": 1, "hard": 2}
PROMPT_TEMPLATE = """You are a Python debugging agent. Fix the broken code in the working directory.
Workflow:
1. list_files β discover what files exist
2. run_tests β see what is failing
3. read_file(path) β read each relevant file
4. edit_file(path, content) β write the complete corrected file
5. run_tests β confirm all tests pass (reward=1.0)
Rules:
- Read ALL files before editing β bugs can span multiple files
- edit_file replaces the ENTIRE file β always provide complete content
- Do NOT stop until reward=1.0
Task: {task_id}
Difficulty: {difficulty}
Description: {description}
Begin with list_files."""
def build_dataset(repeat_easy: int = 10, repeat_medium: int = 6, repeat_hard: int = 3) -> Dataset:
"""
Build curriculum-ordered dataset from TASK_REGISTRY.
Args:
repeat_easy: How many times to repeat each easy task row.
repeat_medium: How many times to repeat each medium task row.
repeat_hard: How many times to repeat each hard task row.
Returns:
HuggingFace Dataset with columns: prompt, task_id, difficulty.
"""
rows = []
repeats = {"easy": repeat_easy, "medium": repeat_medium, "hard": repeat_hard}
for task_id, meta in sorted(
TASK_REGISTRY.items(),
key=lambda x: DIFFICULTY_ORDER.get(x[1].get("difficulty", "medium"), 1),
):
difficulty = meta.get("difficulty", "medium")
n = repeats.get(difficulty, 4)
for _ in range(n):
rows.append(
{
"prompt": PROMPT_TEMPLATE.format(
task_id=task_id,
difficulty=difficulty,
description=meta.get("description", ""),
),
"task_id": task_id,
"difficulty": difficulty,
}
)
return Dataset.from_list(rows)
|