hiyouga/LlamaFactory · error · ValueError
File {local_path} not found.
Error message
File {local_path} not found. What it means
Raised in _load_single_dataset when a dataset entry in dataset_info.json is configured with "file" loading but neither a file nor a directory of that name exists under data_args.dataset_dir. The path is resolved as os.path.join(dataset_dir, dataset_name); a miss yields this ValueError before any loading is attempted.
Source
Thrown at src/llamafactory/data/loader.py:82
elif dataset_attr.load_from == "script":
data_path = os.path.join(data_args.dataset_dir, dataset_attr.dataset_name)
data_name = dataset_attr.subset
data_dir = dataset_attr.folder
elif dataset_attr.load_from == "cloud_file":
data_path = dataset_attr.dataset_name
elif dataset_attr.load_from == "file":
data_files = []
local_path = os.path.join(data_args.dataset_dir, dataset_attr.dataset_name)
if os.path.isdir(local_path): # is directory
for file_name in os.listdir(local_path):
data_files.append(os.path.join(local_path, file_name))
elif os.path.isfile(local_path): # is file
data_files.append(local_path)
else:
raise ValueError(f"File {local_path} not found.")
data_path = FILEEXT2TYPE.get(os.path.splitext(data_files[0])[-1][1:], None)
if data_path is None:
raise ValueError("Allowed file types: {}.".format(",".join(FILEEXT2TYPE.keys())))
if any(data_path != FILEEXT2TYPE.get(os.path.splitext(data_file)[-1][1:], None) for data_file in data_files):
raise ValueError("File types should be identical.")
else:
raise NotImplementedError(f"Unknown load type: {dataset_attr.load_from}.")
if dataset_attr.load_from == "ms_hub":
check_version("modelscope>=1.14.0", mandatory=True)
from modelscope import MsDataset # type: ignore
from modelscope.utils.config_ds import MS_DATASETS_CACHE # type: ignore
cache_dir = model_args.cache_dir or MS_DATASETS_CACHE
dataset = MsDataset.load(
dataset_name=data_path,View on GitHub (pinned to f28afaf635)
Solutions
- Verify the resolved path: check that <dataset_dir>/<dataset_name> exists, where dataset_dir defaults to the built-in data/ directory unless overridden in the YAML.
- Pass an absolute dataset_dir in your training YAML (dataset_dir: /abs/path/to/data) to remove cwd ambiguity.
- Fix the dataset_name/file_name entry in dataset_info.json to match the actual file name including extension.
- If the file lives elsewhere, move or symlink it into the dataset directory.
Example fix
# before (train.yaml + dataset_info.json)
# dataset_info.json: "mydata": {"file_name": "my_data.jsonl"}
# file actually at /datasets/my_data.jsonl
# after
# dataset_info.json: "mydata": {"file_name": "my_data.jsonl"}
# train.yaml:
dataset_dir: /datasets Defensive patterns
Strategy: validation
Validate before calling
import os
def dataset_path_exists(dataset_dir: str, dataset_name: str) -> bool:
p = os.path.join(dataset_dir, dataset_name)
return os.path.isfile(p) or os.path.isdir(p) Try / catch
from datasets import Dataset
try:
_load_single_dataset(attr, model_args, data_args, training_args)
except ValueError as e:
if "not found" in str(e):
# resolve against an absolute dataset_dir and retry once
raise Prevention
- Use absolute dataset_dir in training YAMLs.
- Run a tiny bootstrap script that verifies every dataset_info.json file entry resolves to an existing path.
- Prefer absolute paths in containers/CI where cwd varies.
When it happens
Trigger: dataset_info.json declares {"file": ...} (or the dataset name resolves to load_from == "file") and the referenced file/directory does not exist relative to the dataset_dir (default 'data/'). Common with relative paths, wrong working directory, or a typo in the file name.
Common situations: Running llamafactory-cli train from a different cwd so the relative data/ dir resolves elsewhere; custom dataset_dir not passed; file placed in another folder; case-sensitivity mismatches on Linux; file left out of a container or cloned repo.
Related errors
- Unsupported model type: {getattr(config, 'model_type')}.
- Dataset converter {name} not found.
- Unknown mixing strategy: {data_args.mix_strategy}.
- Cannot specify `val_size` if `eval_dataset` is not None.
- Unsupported protocol in path: {path}. Use 's3://' or 'gs://'
AI-assisted analysis of hiyouga/LlamaFactory@f28afaf635 (2026-08-14).
Data as JSON: /api/errors/20e18d8a187a09cf.
Report an issue: GitHub.