Skip to content

Commit 423f9dc

Browse files
committed
fix comments
1 parent 7837814 commit 423f9dc

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

src/agentscope/tuner/_algorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Algorithm(BaseModel):
1818
group_size: int = Field(
1919
description=(
2020
"The group size for algorithms "
21-
"required group rollout, e.g., GRPO."
21+
"requiring group rollout, e.g., GRPO."
2222
),
2323
default=8,
2424
)

src/agentscope/tuner/_config.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ def to_trinity_config(
2525
experiment_name: str | None = None,
2626
) -> Any:
2727
"""Convert to Trinity-RFT compatible configuration."""
28-
if workflow_func is not None:
29-
check_workflow_function(workflow_func)
30-
if judge_func is not None:
31-
check_judge_function(judge_func)
32-
3328
from trinity.common.config import (
3429
Config,
3530
TasksetConfig,
@@ -54,12 +49,19 @@ def to_trinity_config(
5449

5550
workflow_name = "agentscope_workflow_adapter_v1"
5651
if train_dataset is not None:
57-
config.buffer.explorer_input.taskset = TasksetConfig(
58-
name="train_taskset",
59-
path=train_dataset.path,
60-
split=train_dataset.split,
61-
subset_name=train_dataset.name,
62-
)
52+
if config.buffer.explorer_input.taskset is None:
53+
config.buffer.explorer_input.taskset = TasksetConfig(
54+
name="train_taskset",
55+
path=train_dataset.path,
56+
split=train_dataset.split,
57+
subset_name=train_dataset.name,
58+
)
59+
else:
60+
config.buffer.explorer_input.taskset.path = train_dataset.path
61+
config.buffer.explorer_input.taskset.split = train_dataset.split
62+
config.buffer.explorer_input.taskset.subset_name = (
63+
train_dataset.name
64+
)
6365
config.buffer.total_epochs = train_dataset.total_epochs
6466
config.buffer.total_steps = train_dataset.total_steps
6567
config.buffer.explorer_input.taskset.default_workflow_type = workflow_name

src/agentscope/tuner/_dataset.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
"""Dataset definition for tuner."""
3-
from typing import Optional, Dict
3+
from itertools import islice
4+
from typing import Optional, List
45
from pydantic import BaseModel, Field
56

67

@@ -34,7 +35,7 @@ class Dataset(BaseModel):
3435
default=None,
3536
)
3637

37-
def preview(self, n: int = 5) -> Dict:
38+
def preview(self, n: int = 5) -> List:
3839
"""Preview the dataset information.
3940
4041
Args:
@@ -53,7 +54,8 @@ def preview(self, n: int = 5) -> Dict:
5354
path=self.path,
5455
name=self.name,
5556
split=self.split,
57+
streaming=True,
5658
)
57-
samples = ds[:n]
59+
samples = list(islice(ds, n))
5860
print(json.dumps(samples, indent=2))
5961
return samples

src/agentscope/tuner/_tune.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
from ._judge import JudgeType
55
from ._model import TunerChatModel
66
from ._dataset import Dataset
7-
from ._config import to_trinity_config
7+
from ._config import (
8+
to_trinity_config,
9+
check_judge_function,
10+
check_workflow_function,
11+
)
812
from ._algorithm import Algorithm
913

1014

@@ -35,7 +39,8 @@ def tune(
3539
Defaults to None.
3640
auxiliary_models (dict[str, TunerChatModel], optional): A
3741
dictionary of auxiliary chat models for LLM-as-a-Judge
38-
usage. Defaults to None.
42+
or acting other agents in multi-agent scenarios.
43+
Defaults to None.
3944
algorithm (Algorithm, optional): The tuning algorithm
4045
configuration. Defaults to None.
4146
config_path (str, optional): Path to the learning configuration
@@ -49,6 +54,10 @@ def tune(
4954
"`pip install trinity-rft`.",
5055
) from e
5156

57+
check_workflow_function(workflow_func)
58+
if judge_func is not None:
59+
check_judge_function(judge_func)
60+
5261
config = to_trinity_config(
5362
config_path=config_path,
5463
workflow_func=workflow_func,

0 commit comments

Comments
 (0)