Skip to content

Studio: cached datasets with undeclared splits offer no split options, though the splits load fine #8140

Closed

Description

@BardiaKoopah

Found while reviewing the training-page rework (#7633). hub/services/datasets/local_options.py is new in that PR.

What happens

A cached dataset whose splits are inferred by the loader — rather than declared in the dataset card — is reported as cached with no split options at all, even though its splits load perfectly.

bentrevett/multi30k, straight from my HF cache:

snapshot contents: train.jsonl, test.jsonl, val.jsonl, README.md

local_dataset_options(...) -> cache_available=True, splits=[]

load_cached_hf_dataset(repo, snapshot, split="train")      -> OK, 29000 rows
load_cached_hf_dataset(repo, snapshot, split="test")       -> OK,  1000 rows
load_cached_hf_dataset(repo, snapshot, split="validation") -> OK,  1014 rows

Three usable splits, none offered.

Why

_snapshot_options reads declared metadata only — the README card's configs / dataset_info, then dataset_infos.json / dataset_info.json. bentrevett/multi30k's card front matter has neither:

task_categories:
- translation
language:
- en
- de
size_categories:
- 10K<n<100K

So nothing is discovered. But the loader that eventually runs infers train / validation / test from the data files, which is why the loads above succeed. Datasets uploaded as plain jsonl/csv/parquet without a curated card land in exactly this shape.

Worth noting the module already flags this failure mode in its own comment, about the option grammar rather than discovery:

anything looser is offered and then 422s, anything tighter hides a usable option

Not every empty result is wrong

Two other cached datasets return no options, and for those it is correct — worth stating so a fix does not paper over them:

tatsu-lab/alpaca                 only README.md cached, no data
                                 -> load raises EmptyDatasetError. Empty is right.
programbench/ProgramBench-Tests  a subdirectory of LICENSE/ATTRIBUTION only
                                 -> load raises ValueError (not a loadable format). Empty is right.

So the signal to fix is specifically "the snapshot has loadable data whose splits are undeclared", not "no options were found".

On fixing it

The obvious fallback — read split names off the data filenames — is wrong, and this dataset shows why: the file is val.jsonl, but the loadable split is validation.

load_cached_hf_dataset(..., split="val") -> ValueError: Unknown split "val".
                                            Should be one of ['train', 'validation', 'test'].

Offering val would put the picker straight back into the "offered, then fails" case it is trying to avoid. The names have to come from the loader's own inference (get_dataset_split_names against the local snapshot, or an equivalent), not from the filenames.

That is why I am filing rather than sending a patch: the natural implementation reaches for datasets, and hub/utils/dataset_cache.py carries an explicit constraint against importing it on cache paths —

Keep this stdlib-only. Training validates cached datasets before activating a Transformers sidecar, and importing datasets here would cache the base huggingface_hub module before the sidecar can provide its matching version.

I have not established whether that constraint binds this route the way it binds the training path, and guessing wrong would trade a cosmetic gap for a sidecar-versioning bug. Happy to implement it whichever way you prefer, including a lazy import confined to this service if that is safe here.

Reproducing

Cache any dataset that ships data files without configs: or dataset_info: in its card, then call the local-options service for it. bentrevett/multi30k is a ready example.

Tested on an M2 MacBook Air (16GB), backend at e96d02074, datasets 4.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions