hiyouga/LlamaFactory · error · ValueError
Undefined dataset {name} in {DATA_CONFIG}.
Error message
Undefined dataset {name} in {DATA_CONFIG}. What it means
Raised when a requested dataset name has no entry in the loaded dataset_info.json dict. Every name in the `dataset` field must be a key in that config (defining file_name, columns, formatting, etc.) before it can be loaded.
Source
Thrown at src/llamafactory/data/parser.py:126
try:
with open(config_path) as f:
dataset_info = json.load(f)
except Exception as err:
if len(dataset_names) != 0:
raise ValueError(f"Cannot open {config_path} due to {str(err)}.")
dataset_info = None
dataset_list: list[DatasetAttr] = []
for name in dataset_names:
if dataset_info is None: # dataset_dir is ONLINE
load_from = "ms_hub" if use_modelscope() else "om_hub" if use_openmind() else "hf_hub"
dataset_attr = DatasetAttr(load_from, dataset_name=name)
dataset_list.append(dataset_attr)
continue
if name not in dataset_info:
raise ValueError(f"Undefined dataset {name} in {DATA_CONFIG}.")
has_hf_url = "hf_hub_url" in dataset_info[name]
has_ms_url = "ms_hub_url" in dataset_info[name]
has_om_url = "om_hub_url" in dataset_info[name]
if has_hf_url or has_ms_url or has_om_url:
if has_ms_url and (use_modelscope() or not has_hf_url):
dataset_attr = DatasetAttr("ms_hub", dataset_name=dataset_info[name]["ms_hub_url"])
elif has_om_url and (use_openmind() or not has_hf_url):
dataset_attr = DatasetAttr("om_hub", dataset_name=dataset_info[name]["om_hub_url"])
else:
dataset_attr = DatasetAttr("hf_hub", dataset_name=dataset_info[name]["hf_hub_url"])
elif "script_url" in dataset_info[name]:
dataset_attr = DatasetAttr("script", dataset_name=dataset_info[name]["script_url"])
elif "cloud_file_name" in dataset_info[name]:
dataset_attr = DatasetAttr("cloud_file", dataset_name=dataset_info[name]["cloud_file_name"])
else:
dataset_attr = DatasetAttr("file", dataset_name=dataset_info[name]["file_name"])View on GitHub (pinned to f28afaf635)
Solutions
- Open dataset_info.json and add an entry for the missing name, e.g. `"my_data": {"file_name": "my_data.json"}` with the data file placed in the same directory.
- Or change the YAML dataset field to a name that already exists in dataset_info.json.
- Check exact spelling and case; JSON keys are case-sensitive.
Example fix
### before
# dataset_info.json has no "my_data" key; yaml uses
dataset: my_data
### after
# data/dataset_info.json
"my_data": {"file_name": "my_data.json", "formatting": "sharegpt", ...}
# yaml unchanged Defensive patterns
Strategy: validation
Validate before calling
import json, os
cfg = json.load(open(os.path.join(dataset_dir, 'dataset_info.json')))
missing = [d for d in dataset_names if d not in cfg]
assert not missing, f'undefined datasets: {missing}; defined: {sorted(cfg)}' Prevention
- Keep dataset names in the YAML and keys in dataset_info.json generated from one source of truth.
- Names are case-sensitive; avoid renames late in a run setup.
When it happens
Trigger: YAML dataset: my_data while dataset_info.json only defines e.g. 'alpaca_zh'; renaming a dataset in the config but not the YAML (or vice versa); trailing spaces in the name.
Common situations: Copy-paste example configs that reference datasets not present in the user's dataset_info.json; case sensitivity ('Alpaca' vs 'alpaca'); editing the JSON but forgetting to save/re-run.
Related errors
- Cannot open {config_path} due to {str(err)}.
- Invalid JSON format in function message: {str([content])}.
- Invalid JSON format in tool description: {str([content])}.
- Multimodal plugin `{name}` not found.
- Unknown identifier: {node.id}
AI-assisted analysis of hiyouga/LlamaFactory@f28afaf635 (2026-08-14).
Data as JSON: /api/errors/fc13fe20b0820eed.
Report an issue: GitHub.