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

  1. 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.
  2. Pass an absolute dataset_dir in your training YAML (dataset_dir: /abs/path/to/data) to remove cwd ambiguity.
  3. Fix the dataset_name/file_name entry in dataset_info.json to match the actual file name including extension.
  4. 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

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


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