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
36import random
47from dataclasses import dataclass
912
1013DATASET_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
1432class 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