{"record":{"id":"44c58802af14e7d2","repo":"hiyouga/LlamaFactory","slug":"cannot-specify-val-size-if-dataset-is-none","errorCode":null,"errorMessage":"Cannot specify `val_size` if `dataset` is None.","messagePattern":"Cannot specify `val_size` if `dataset` is None\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/hparams/data_args.py","lineNumber":160,"sourceCode":"    data_shared_file_system: bool = field(\n        default=False,\n        metadata={\"help\": \"Whether or not to use a shared file system for the datasets.\"},\n    )\n\n    def __post_init__(self):\n        def split_arg(arg):\n            if isinstance(arg, str):\n                return [item.strip() for item in arg.split(\",\")]\n            return arg\n\n        self.dataset = split_arg(self.dataset)\n        self.eval_dataset = split_arg(self.eval_dataset)\n\n        if self.media_dir is None:\n            self.media_dir = self.dataset_dir\n\n        if self.dataset is None and self.val_size > 1e-6:\n            raise ValueError(\"Cannot specify `val_size` if `dataset` is None.\")\n\n        if self.eval_dataset is not None and self.val_size > 1e-6:\n            raise ValueError(\"Cannot specify `val_size` if `eval_dataset` is not None.\")\n\n        if self.interleave_probs is not None:\n            if self.mix_strategy == \"concat\":\n                raise ValueError(\"`interleave_probs` is only valid for interleaved mixing.\")\n\n            self.interleave_probs = list(map(float, split_arg(self.interleave_probs)))\n            if self.dataset is not None and len(self.dataset) != len(self.interleave_probs):\n                raise ValueError(\"The length of dataset and interleave probs should be identical.\")\n\n            if self.eval_dataset is not None and len(self.eval_dataset) != len(self.interleave_probs):\n                raise ValueError(\"The length of eval dataset and interleave probs should be identical.\")\n\n        if self.streaming and self.val_size > 1e-6 and self.val_size < 1:\n            raise ValueError(\"Streaming mode should have an integer val size.\")\n","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/hparams/data_args.py#L142-L178","documentation":"DataArguments post-init validates that val_size (a float: fraction if <1, absolute count if >=1) is only meaningful when a training dataset exists. If dataset is None but val_size > 1e-6, it raises ValueError — you cannot carve a validation split out of nothing.","triggerScenarios":"A YAML config with eval_dataset unset, dataset unset (e.g. a pure-eval or chat entry misused for training), but val_size: 0.1 still present; leftover val_size from a template config after removing dataset.","commonSituations":"Copying a training YAML and deleting the dataset lines for a quick test run; misconfigured webui exports that keep val_size with no dataset; switching to eval-only workflows without cleaning val_size.","solutions":["Remove val_size from the config (or set val_size: 0) when no training dataset is used.","If you intended to train, add the dataset (and its dataset_info.json entry).","If you only want evaluation, supply eval_dataset and drop val_size entirely."],"exampleFix":"# before\n### dataset\ndataset: null\nval_size: 0.1\n\n# after\n### dataset\ndataset: alpaca_demo\nval_size: 0.1","handlingStrategy":"validation","validationCode":"assert not (data_args.dataset is None and data_args.val_size > 1e-6), \\\n    \"val_size requires a training dataset\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When removing dataset from a config, also remove val_size.","Treat val_size as tied to dataset; treat eval_dataset as the alternative validation source."],"tags":["config","data-args","validation-split"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}