Download src/study/design.py from BurnyCoder/recursive-judge-grpo-study: direct link, hf CLI and curl.
- Browser
- Download file 3.46 kB
-
https://huggingface.co/datasets/BurnyCoder/recursive-judge-grpo-study/resolve/main/src/study/design.py
- Command line
-
hf download hf://datasets/BurnyCoder/recursive-judge-grpo-study/src/study/design.py
-
curl -L -o design.py https://huggingface.co/datasets/BurnyCoder/recursive-judge-grpo-study/resolve/main/src/study/design.py
3.46 kB
| """One dependency-ordered manifest drives training, publication, and analysis.""" | |
| from dataclasses import dataclass, replace | |
| SEEDS = (17, 29, 43) | |
| PILOTS = ("learn-oracle-17","learn-shuffle-17") | |
| ROUTES = {"exact":("exact-j1","exact-j2","exact-j3"), "top":("top-j1","top-j2","exact-j3")} | |
| MATCHED_NAMES = tuple(f"{route}-depth{d}" for route in ROUTES for d in (1,2)) | |
| BASE = "Qwen/Qwen2.5-1.5B-Instruct" | |
| REVISION = "989aa7980e4cf806f80c7fef2b1adb7bc71aa306" | |
| PROJECT = "verifying-verifier-of-verifier-llm-reinforcement-learning" | |
| GITHUB = f"https://github.com/BurnyCoder/{PROJECT}" | |
| PAGES = f"https://burnycoder.github.io/{PROJECT}/" | |
| class Run: | |
| name: str | |
| seed: int = 17 | |
| role: str = "solver" | |
| reward: str = "d3" | |
| judges: tuple = (None, None, None) | |
| initial: str | None = None | |
| teacher: str | None = None | |
| corpus: str = "base" | |
| family: str | None = None | |
| prompt_style: str = "registered" | |
| def dependencies(self): | |
| sources = (*self.judges, self.initial, self.teacher, None if self.corpus == "base" else self.corpus) | |
| return tuple(dict.fromkeys(x for x in sources if x)) | |
| def matrix(profile=None): | |
| if profile is None: | |
| from .benchmark import active_profile | |
| profile = active_profile() | |
| rows = [Run(f"{arm}-17", reward=arm) for arm in ("d3", "d2", "d1", "flat", "oracle", "hybrid", "shuffle")] | |
| direct, top = ROUTES["exact"], ROUTES["top"] | |
| rows.extend(Run(name, role=f"j{i}", reward="exact") for i, name in enumerate(direct, 1)) | |
| rows.extend((Run(top[1], role="j2", reward="teacher", teacher=direct[2]), | |
| Run(top[0], role="j1", reward="teacher", teacher=top[1]))) | |
| for route, judges in (("exact", direct), ("top", top)): | |
| for prefix in (1, 2, 3): | |
| rows.append(Run(f"{route}-prefix{prefix}", judges=judges[:prefix]+(None,)*(3-prefix))) | |
| for route, judges in (("exact", direct), ("top", top)): | |
| current = list(judges) | |
| corpus = f"{route}-prefix3" | |
| for index in ((0, 1, 2) if route == "exact" else (2, 1, 0)): | |
| name = f"alt-{route}-j{index+1}" | |
| teacher = current[index+1] if route == "top" and index < 2 else None | |
| rows.append(Run(name, role=f"j{index+1}", reward="teacher" if teacher else "exact", | |
| teacher=teacher, initial=current[index], corpus=corpus)) | |
| current[index] = name | |
| rows.append(Run(f"alt-{route}-solver", judges=tuple(current), initial=corpus, corpus=corpus)) | |
| rows.extend(Run(f"{arm}-{seed}", seed=seed, reward=arm) for seed in SEEDS[1:] for arm in ("d3", "d2", "flat")) | |
| if profile: | |
| return [replace(row, family=profile["family"], prompt_style=profile["style"]) for row in rows] | |
| return rows | |
| def matched_runs(profile): | |
| """Clone each fresh deep solver's complete training recipe and vary only the reward depth.""" | |
| if not profile: | |
| return [] | |
| originals = {r.name:r for r in matrix(profile)} | |
| return [replace(originals[route+"-prefix3"],name=f"{route}-depth{level}",reward=f"d{level}") | |
| for route in ROUTES for level in (1,2)] | |
| def permute_groups(values, rng): | |
| if len(values) % 4: | |
| raise ValueError("A shuffled GRPO reward requires complete groups of four") | |
| result = [] | |
| for offset in range(0, len(values), 4): | |
| group = list(values[offset:offset+4]) | |
| rng.shuffle(group) | |
| result.extend(group) | |
| return result | |