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

get_dataset raises ValueError('Either `dataset_name` or `dataset_mixture` must be provided') when neither args.dataset_name nor args.dataset_mixture is set. The function requires exactly one data source; with neither it cannot load anything. This is a config-validation error at the very start of data loading.

Source

Thrown at src/open_r1/utils/data.py:65

            combined_dataset = concatenate_datasets(datasets_list)
            combined_dataset = combined_dataset.shuffle(seed=seed)
            logger.info(f"Created dataset mixture with {len(combined_dataset)} examples")

            if args.dataset_mixture.test_split_size is not None:
                combined_dataset = combined_dataset.train_test_split(
                    test_size=args.dataset_mixture.test_split_size, seed=seed
                )
                logger.info(
                    f"Split dataset into train and test sets with test size: {args.dataset_mixture.test_split_size}"
                )
                return combined_dataset
            else:
                return DatasetDict({"train": combined_dataset})
        else:
            raise ValueError("No datasets were loaded from the mixture configuration")

    else:
        raise ValueError("Either `dataset_name` or `dataset_mixture` must be provided")

View on GitHub (pinned to 1416fa0cf2)

Solutions

  1. Pass --dataset_name <hub_id> (with optional --dataset_config) on the command line
  2. Or configure dataset_mixture in the YAML/args with a non-empty datasets list
  3. Print/inspect the resolved ScriptArguments before calling get_dataset
  4. Check documentation for the current argument names after upgrading open-r1

Example fix

// before
args = ScriptArguments()
dataset = get_dataset(args)
// after
args = ScriptArguments(dataset_name="HuggingFaceH4/ultrachat_200k")
dataset = get_dataset(args)
Defensive patterns

Strategy: validation

Validate before calling

def validate_data_source(args):
    if not args.dataset_name and not args.dataset_mixture:
        raise ValueError("Provide either --dataset_name or a dataset_mixture config before training")

Type guard

def has_data_source(args):
    return bool(args.dataset_name) or bool(args.dataset_mixture)

Prevention

When it happens

Trigger: Calling get_dataset(ScriptArguments(...)) with dataset_name=None and dataset_mixture=None — e.g. launching a training/eval script without --dataset_name and without a dataset_mixture config.

Common situations: Forgotten --dataset_name CLI flag, YAML config missing the dataset key, relying on a renamed argument after a version change, programmatically constructing ScriptArguments with defaults left unset.

Understand the failure class

Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.

Related errors


AI-assisted analysis of huggingface/open-r1@1416fa0cf2 (2026-08-30). Data as JSON: /api/errors/18286f8e09327c63. Report an issue: GitHub.