huggingface/open-r1 · error
Either `dataset_name` or `dataset_mixture` must be provided
Error message
Either `dataset_name` or `dataset_mixture` must be provided
What it means
The training script's dataset config (DatasetConfig.__post_init__) requires that you identify the training data either via dataset_name (a single HF Hub dataset) or dataset_mixture (a multi-dataset mixture dict). If both are None, the dataclass immediately raises this ValueError at config-construction time, because the trainer would otherwise have no data to load.
Source
Thrown at src/open_r1/configs.py:80
- col1
- col2
weight: 0.5
seed: 42
test_split_size: 0.1
"""
# Override the dataset_name to make it optional
dataset_name: Optional[str] = field(
default=None, metadata={"help": "Dataset name. Can be omitted if using dataset_mixture."}
)
dataset_mixture: Optional[dict[str, Any]] = field(
default=None,
metadata={"help": "Configuration for creating dataset mixtures with advanced options like shuffling."},
)
def __post_init__(self):
if self.dataset_name is None and self.dataset_mixture is None:
raise ValueError("Either `dataset_name` or `dataset_mixture` must be provided")
if self.dataset_mixture is not None:
if not isinstance(self.dataset_mixture, dict) or "datasets" not in self.dataset_mixture:
raise ValueError(
"dataset_mixture must be a dictionary with a 'datasets' key. "
"Expected format: {'datasets': [...], 'seed': int}"
)
datasets_list = []
datasets_data = self.dataset_mixture.get("datasets", [])
if isinstance(datasets_data, list):
for dataset_config in datasets_data:
datasets_list.append(
DatasetConfig(
id=dataset_config.get("id"),
config=dataset_config.get("config"),
split=dataset_config.get("split", "train"),View on GitHub (pinned to 1416fa0cf2)
Solutions
- Pass a dataset name: dataset_name="HuggingFaceH4/ultrachat_200k" (or --dataset_name on the CLI).
- Or provide a mixture dict: dataset_mixture={"datasets": [{"id": "ds1"}, {"id": "ds2"}], "seed": 42}.
- Check your YAML/JSON/CLI arg spelling so the value actually populates dataset_name/dataset_mixture.
Example fix
// before args = SFTConfig(output_dir="out") # dataset_name=None, dataset_mixture=None -> ValueError // after args = SFTConfig(output_dir="out", dataset_name="HuggingFaceH4/ultrachat_200k")
Defensive patterns
Strategy: validation
Validate before calling
cfg = DatasetConfig(dataset_name=args.get("dataset_name"), dataset_mixture=args.get("dataset_mixture"))
if cfg.dataset_name is None and cfg.dataset_mixture is None:
raise SystemExit("Set --dataset_name or --dataset_mixture before launching training") Type guard
def has_dataset(cfg) -> bool:
return getattr(cfg, "dataset_name", None) is not None or getattr(cfg, "dataset_mixture", None) is not None Try / catch
try:
cfg = DatasetConfig(**raw_args)
except ValueError as e:
if "dataset_name" in str(e) or "dataset_mixture" in str(e):
sys.exit("Config error: provide --dataset_name or --dataset_mixture")
raise Prevention
- Always set dataset_name or dataset_mixture in training YAML templates
- Validate configs with a dry-run/parse-only step before launching multi-GPU jobs
- Keep exact key names dataset_name/dataset_mixture; avoid near-miss spellings
When it happens
Trigger: Instantiating the SFT/GRPO/DPO config dataclass (e.g. via HfArgumentParser from CLI args or in Python) with neither --dataset_name nor --dataset_mixture set.
Common situations: New training configs copied from templates where the dataset fields were deleted; CLI runs that omitted the dataset flag; YAML/JSON configs where the key is misspelled (e.g. dataset_names) so it lands nowhere; script defaults where dataset_name=None was left in place.
Related errors
- dataset_mixture must be a dictionary with a 'datasets' key.
- 'datasets' must be a list of dataset configurations
- Column names must be consistent across all dataset configura
- CF_TESTS_FOLDER environment variable not set! Please downloa
- Dataset Question Field Error: {prompt_column} is not support
AI-assisted analysis of huggingface/open-r1@1416fa0cf2 (2026-08-30).
Data as JSON: /api/errors/90f27a571826d0f6.
Report an issue: GitHub.