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

Load huggingface data with revision #5233

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
1 change: 1 addition & 0 deletions src/llamafactory/data/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def _load_single_dataset(
token=model_args.hf_hub_token,
streaming=(data_args.streaming and (dataset_attr.load_from != "file")),
trust_remote_code=True,
revision=dataset_attr.revision,
)

if data_args.streaming and (dataset_attr.load_from == "file"): # faster than specifying streaming=True
Expand Down
7 changes: 6 additions & 1 deletion src/llamafactory/data/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class DatasetAttr:
split: str = "train"
folder: Optional[str] = None
num_samples: Optional[int] = None
revision: Optional[str] = None
# common columns
system: Optional[str] = None
tools: Optional[str] = None
Expand Down Expand Up @@ -112,7 +113,11 @@ def get_dataset_list(dataset_names: Optional[Sequence[str]], dataset_dir: str) -
if (use_modelscope() and has_ms_url) or (not has_hf_url):
dataset_attr = DatasetAttr("ms_hub", dataset_name=dataset_info[name]["ms_hub_url"])
else:
dataset_attr = DatasetAttr("hf_hub", dataset_name=dataset_info[name]["hf_hub_url"])
dataset_attr = DatasetAttr(
"hf_hub",
dataset_name=dataset_info[name]["hf_hub_url"],
revision=dataset_info[name].get("revision")
)
elif "script_url" in dataset_info[name]:
dataset_attr = DatasetAttr("script", dataset_name=dataset_info[name]["script_url"])
else:
Expand Down