Skip to content

Commit db95da4

Browse files
Wangbiao2wangbiao11
andauthored
[config] supports loading format prompt from a file (#208)
* Supports loading format prompt from a file * [fix] loading format prompt from a file. --------- Co-authored-by: wangbiao11 <[email protected]>
1 parent d6decc6 commit db95da4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

verl/trainer/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,19 @@ class DataConfig:
4343
rollout_batch_size: int = 512
4444
val_batch_size: int = -1
4545
format_prompt: Optional[str] = None
46+
format_prompt_path: Optional[str] = None
4647
shuffle: bool = True
4748
seed: int = 1
4849
max_pixels: int = 4194304
4950
min_pixels: int = 262144
5051

52+
def post_init(self):
53+
if self.format_prompt is None and self.format_prompt_path is not None:
54+
if os.path.exists(self.format_prompt_path):
55+
self.format_prompt_path = os.path.abspath(self.format_prompt_path)
56+
with open(self.format_prompt_path, "r", encoding="utf-8") as f:
57+
self.format_prompt = f.read()
58+
5159

5260
@dataclass
5361
class AlgorithmConfig:

0 commit comments

Comments
 (0)