forked from MakazhanAlpamys/Soup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_common.py
More file actions
29 lines (22 loc) · 980 Bytes
/
Copy path_common.py
File metadata and controls
29 lines (22 loc) · 980 Bytes
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
"""Shared scaffold for the bundled rollout envs — v0.71.30.
Each env module supplies a per-row generator over a seeded ``random.Random``;
this helper owns the deterministic seeding + fixed row count so the three env
modules stay tiny and cannot drift on the boilerplate.
"""
from __future__ import annotations
import random
from collections.abc import Callable
# Fixed curriculum size per env (deterministic; overridable by callers).
DEFAULT_ROWS = 64
def seeded_rows(
seed: int,
make_row: Callable[[random.Random], dict[str, str]],
count: int = DEFAULT_ROWS,
) -> list[dict[str, str]]:
"""Build ``count`` deterministic ``{"prompt","answer"}`` rows.
A fresh ``random.Random(seed)`` is created on every call, so the output is
identical across calls (determinism the tests assert). ``make_row`` receives
that RNG and returns one ``{"prompt","answer"}`` row.
"""
rng = random.Random(seed)
return [make_row(rng) for _ in range(count)]