Skip to content

Resolves #87 - Exposing num_proc in standardize_data_formats #88

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 15 additions & 8 deletions unsloth_zoo/dataset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ def standardize_data_formats(
aliases_for_system = ["system",],
aliases_for_user = ["user", "human", "input",],
aliases_for_assistant = ["gpt", "assistant", "output",],
num_proc = None,
):
"""
Standardizes ShareGPT and other formats to user/assistant Hugging Face format.
Expand Down Expand Up @@ -456,14 +457,20 @@ def _standardize_dataset(examples):
pass

from multiprocessing import cpu_count
num_proc = cpu_count()

return dataset.map(
_standardize_dataset,
batched = True,
desc = "Unsloth: Standardizing formats",
num_proc = num_proc,
)
if num_proc is None or not isinstance(num_proc, int):
num_proc = cpu_count()

try:
return dataset.map(
_standardize_dataset,
batched=True,
desc="Unsloth: Standardizing formats",
num_proc=num_proc,
)
except RuntimeError as e:
raise RuntimeError(
f"Unsloth: Process crashed: {str(e)}\nTry reducing num_proc (currently {num_proc}) to a lower value."
) from e
pass


Expand Down