hiyouga/LlamaFactory · error · ValueError

Unknown mixing strategy: {data_args.mix_strategy}.

Error message

Unknown mixing strategy: {data_args.mix_strategy}.

What it means

In the dataset-mixing helper, only mix_strategy values 'concat' (implicit else-branch) and the interleave strategies mapped to HF stopping strategies are accepted; anything else reaches the final else and raises ValueError with the offending value. data_args.mix_strategy comes from the training YAML.

Source

Thrown at src/llamafactory/data/data_utils.py:82

    elif data_args.mix_strategy.startswith("interleave"):
        if not data_args.streaming:
            logger.warning_rank0_once("We recommend using `mix_strategy=concat` in non-streaming mode.")

        strategy_map: str = {
            "interleave_under": "first_exhausted",
            "interleave_over": "all_exhausted",
            "interleave_once": "all_exhausted_without_replacement",
        }[data_args.mix_strategy]

        return interleave_datasets(
            datasets=all_datasets,
            probabilities=data_args.interleave_probs,
            seed=seed,
            stopping_strategy=strategy_map,  # type: ignore
        )

    else:
        raise ValueError(f"Unknown mixing strategy: {data_args.mix_strategy}.")


def split_dataset(
    dataset: Optional[Union["Dataset", "IterableDataset"]],
    eval_dataset: Optional[Union["Dataset", "IterableDataset", dict[str, "Dataset"]]],
    data_args: "DataArguments",
    seed: int,
) -> tuple[dict, dict]:
    r"""Split the dataset and returns two dicts containing train set and validation set.

    Support both map dataset and iterable dataset.

    Returns:
        train_dict: Dictionary containing training data with key "train"
        eval_dict: Dictionary containing evaluation data with keys "validation" or "validation_{name}"
    """
    if eval_dataset is not None and data_args.val_size > 1e-6:
        raise ValueError("Cannot specify `val_size` if `eval_dataset` is not None.")

View on GitHub (pinned to f28afaf635)

Solutions

  1. Use one of the supported values: concat (default), interleave_under, interleave_over, interleave_once.
  2. For interleave strategies also set interleave_probs matching the number of datasets.
  3. Check DataArguments.mix_strategy docstring/source for the authoritative list on your version.

Example fix

# before (yaml)
mix_strategy: random

# after (yaml)
mix_strategy: interleave_under
interleave_probs: [0.7, 0.3]
Defensive patterns

Strategy: validation

Validate before calling

VALID = {"concat", "interleave_under", "interleave_over", "interleave_once"}
assert data_args.mix_strategy in VALID, f"mix_strategy must be one of {sorted(VALID)}"

Prevention

When it happens

Trigger: Setting mix_strategy: undersample / random / any typo (e.g. 'interleave-over') in the training config; the only valid values are concat, interleave_under, interleave_over, interleave_once.

Common situations: Copy-pasted YAML from other frameworks whose mixing vocabularies differ; guessing a strategy name instead of checking DataArguments docs; casing/typo errors.

Related errors


AI-assisted analysis of hiyouga/LlamaFactory@f28afaf635 (2026-08-14). Data as JSON: /api/errors/d2038e9ffa50b5d1. Report an issue: GitHub.