hiyouga/LlamaFactory · error · ValueError

Allowed file types: {}.

Error message

Allowed file types: {}.

What it means

Raised when a local dataset file's extension is not a key in FILEEXT2TYPE, the map of supported dataset formats (json, jsonl, csv, parquet, and similar). The extension is taken from the first file found (os.path.splitext(data_files[0])[-1][1:]); an unmapped extension produces None and this ValueError listing the allowed types.

Source

Thrown at src/llamafactory/data/loader.py:86

        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,
            subset_name=data_name,
            data_dir=data_dir,
            data_files=data_files,
            split=dataset_attr.split,

View on GitHub (pinned to f28afaf635)

Solutions

  1. Convert the file to one of the allowed types listed in the message — most simply JSONL (one JSON object per line) or CSV.
  2. Rename to a supported exact extension (.json, .jsonl, .csv, .parquet) and remove double extensions.
  3. For Excel/other formats, export to CSV/JSON first with pandas or another tool.
  4. If the data is gzipped, decompress it so the final extension matches a supported type.

Example fix

# before
"mydata": {"file_name": "conversations.xlsx"}

# after (convert once)
import pandas as pd
pd.read_excel("data/conversations.xlsx").to_json("data/conversations.jsonl", orient="records", lines=True, force_ascii=False)
# "mydata": {"file_name": "conversations.jsonl"}
Defensive patterns

Strategy: validation

Validate before calling

from llamafactory.extras.constants import FILEEXT2TYPE
import os

def ext_supported(path: str) -> bool:
    return os.path.splitext(path)[-1][1:] in FILEEXT2TYPE

Prevention

When it happens

Trigger: Pointing a "file"-type dataset at a .txt, .xlsx, .arrow, .json.gz, or extensionless file; also when a dataset directory's first listed entry has an unusual extension even if other files are supported.

Common situations: Users dropping raw exported spreadsheets or text logs into data/; double extensions like data.jsonl.backup; uppercase extensions on case-sensitive filesystems; gzipped JSONL files.

Related errors


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