Skip to content

Commit 641712e

Browse files
committed
rm teacherless mode
1 parent 18ff986 commit 641712e

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

reasoning_gym/graphs/path_star.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
"""Inspired by https://arxiv.org/pdf/2403.06963"""
1+
"""
2+
Pathfinding problems in a path-star graph structure.
3+
Inspired by https://arxiv.org/pdf/2403.06963
4+
"""
25

36
import random
47
from dataclasses import dataclass
@@ -9,6 +12,21 @@
912

1013
DATASET_NAME = "path_star"
1114

15+
PROMPT_TEMPLATE = """
16+
Find a path from the start node to the goal node in the following path-star graph.
17+
Respond with only the sequence of node labels in the path, including the start and goal nodes.
18+
Separate node labels with a single space.
19+
20+
The graph is represented as a list of edges, where each edge is defined by two node labels.
21+
The edges are separated by a vertical bar '|'. Then, the start and goal nodes are specified after a slash '/'.
22+
23+
Example:
24+
|1 2|1 3|2 4|3 5/1 5 = 1 3 5
25+
26+
Solve the following task:
27+
{task}
28+
"""
29+
1230

1331
@dataclass
1432
class PathStarConfig:
@@ -18,7 +36,6 @@ class PathStarConfig:
1836
max_path_length: int = 5
1937

2038
reversed: bool = False
21-
teacherless: bool = False
2239

2340
size: int = 500 # Virtual dataset size
2441
seed: Optional[int] = None
@@ -64,21 +81,17 @@ def __getitem__(self, idx: int) -> dict[str, Any]:
6481
rng.shuffle(edges)
6582

6683
edges_str = "".join(f"|{u} {v}" for u, v in edges)
67-
prefix = f"{edges_str}/{center} {goal} ="
84+
prefix = f"{edges_str}/{center} {goal} = "
85+
question = PROMPT_TEMPLATE.format(task=prefix)
6886

6987
# gold path
7088
gold = [center] + goal_path
7189
if cfg.reversed:
7290
gold = list(reversed(gold))
7391
answer = " ".join(map(str, gold))
7492

75-
if cfg.teacherless:
76-
q = prefix + " $" * len(gold) # same length dummy token(s)
77-
else:
78-
q = prefix + " "
79-
8093
return {
81-
"question": q,
94+
"question": question,
8295
"answer": answer,
8396
"metadata": {
8497
"center": center,

0 commit comments

Comments
 (0)