Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add custom dataset config file as input #6129

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/llamafactory/data/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def _get_merged_dataset(
return None

datasets = []
for dataset_attr in get_dataset_list(dataset_names, data_args.dataset_dir):
# for dataset_attr in get_dataset_list(dataset_names, data_args.dataset_dir):
for dataset_attr in get_dataset_list(dataset_names, data_args.dataset_dir, data_args.custom_config):
if (stage == "rm" and dataset_attr.ranking is False) or (stage != "rm" and dataset_attr.ranking is True):
raise ValueError("The dataset is not applicable in the current training stage.")

Expand Down
6 changes: 4 additions & 2 deletions src/llamafactory/data/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def set_attr(self, key: str, obj: Dict[str, Any], default: Optional[Any] = None)
setattr(self, key, obj.get(key, default))


def get_dataset_list(dataset_names: Optional[Sequence[str]], dataset_dir: str) -> List["DatasetAttr"]:
# def get_dataset_list(dataset_names: Optional[Sequence[str]], dataset_dir: str) -> List["DatasetAttr"]:
def get_dataset_list(dataset_names: Optional[Sequence[str]], dataset_dir: str, custom_config: str) -> List["DatasetAttr"]:
r"""
Gets the attributes of the datasets.
"""
Expand All @@ -84,7 +85,8 @@ def get_dataset_list(dataset_names: Optional[Sequence[str]], dataset_dir: str) -
if dataset_dir.startswith("REMOTE:"):
config_path = cached_file(path_or_repo_id=dataset_dir[7:], filename=DATA_CONFIG, repo_type="dataset")
else:
config_path = os.path.join(dataset_dir, DATA_CONFIG)
# config_path = os.path.join(dataset_dir, DATA_CONFIG)
config_path = os.path.join(dataset_dir, DATA_CONFIG if custom_config is None else custom_config)

try:
with open(config_path) as f:
Expand Down
4 changes: 4 additions & 0 deletions src/llamafactory/hparams/data_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class DataArguments:
dataset_dir: str = field(
default="data",
metadata={"help": "Path to the folder containing the datasets."},
)
custom_config: Optional[str] = field(
default=None,
metadata={"help": "The path of custom config to use for training. ."},
)
image_dir: Optional[str] = field(
default=None,
Expand Down