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

Catch bad split regex #1691

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
9 changes: 9 additions & 0 deletions llmfoundry/data/finetuning/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def preprocessing_fn(example: Dict) -> Dict[str, str]:
ALLOWED_MESSAGES_KEYS,
ALLOWED_PROMPT_KEYS,
ALLOWED_RESPONSE_KEYS,
BadDatasetSplitError,
ChatTemplateError,
ConsecutiveRepeatedChatRolesError,
DatasetTooSmallError,
Expand Down Expand Up @@ -1047,6 +1048,14 @@ def dataset_mapper(example: dict):
dataset_name=dataset_name,
split=split,
) from error
elif isinstance(error, ValueError) and 'Split name should match' in str(
error,
):
log.error('Huggingface split ValueError during data prep.')
raise BadDatasetSplitError(
dataset_name=dataset_name,
split=split,
) from error
if error is not None:
log.error('Error during data prep')
raise error
Expand Down
12 changes: 12 additions & 0 deletions llmfoundry/utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,18 @@ def __init__(self, dataset_name: str, split: Optional[str] = None) -> None:
super().__init__(message, dataset_name=dataset_name, split=split)


class BadDatasetSplitError(UserError):
"""Error thrown when a HuggingFace dataset is misconfigured."""

def __init__(self, dataset_name: str, split: Optional[str] = None) -> None:
reg = r"^\\w+(\\.\\w+)*$"
message = f'Your dataset (name={dataset_name}, split={split}) has an invalid split. ' + \
f'Please check your split name to make sure it matches the pattern "{reg}"' \
if split is not None else f'Your dataset (name={dataset_name}) is misconfigured. ' + \
f'Please check your split name to make sure it matches the pattern "{reg}"'
super().__init__(message, dataset_name=dataset_name, split=split)


class InvalidDatasetError(UserError):
"""Error thrown when a dataset contains no valid samples for training."""

Expand Down
Loading