hiyouga/LlamaFactory · error · ValueError

Audio feature extractor was not found, please check and upda

Error message

Audio feature extractor was not found, please check and update your model file.

What it means

Audio analogue in _validate_inputs: the plugin has an audio_token but no feature_extractor can be resolved (neither processor.feature_extractor nor processor.audio_processor). Without a SequenceFeatureExtractor the audio samples cannot be prepared, so the error asks you to check/update the model files.

Source

Thrown at src/llamafactory/data/mm_plugin.py:187

                "This model does not support video input. Please check whether the correct `template` is used."
            )

        if len(audios) != 0 and self.audio_token is None:
            raise ValueError(
                "This model does not support audio input. Please check whether the correct `template` is used."
            )

        if self.image_token is not None and processor is None:
            raise ValueError("Processor was not found, please check and update your model file.")

        if self.image_token is not None and image_processor is None:
            raise ValueError("Image processor was not found, please check and update your model file.")

        if self.video_token is not None and video_processor is None:
            raise ValueError("Video processor was not found, please check and update your model file.")

        if self.audio_token is not None and feature_extractor is None:
            raise ValueError("Audio feature extractor was not found, please check and update your model file.")

    def _validate_messages(
        self,
        messages: list[dict[str, str]],
        images: list["ImageInput"],
        videos: list["VideoInput"],
        audios: list["AudioInput"],
    ):
        r"""Validate if the number of images, videos and audios match the number of placeholders in messages."""
        num_image_tokens, num_video_tokens, num_audio_tokens = 0, 0, 0
        for message in messages:
            num_image_tokens += message["content"].count(IMAGE_PLACEHOLDER)
            num_video_tokens += message["content"].count(VIDEO_PLACEHOLDER)
            num_audio_tokens += message["content"].count(AUDIO_PLACEHOLDER)

        if len(images) != num_image_tokens:
            raise ValueError(
                f"The number of images does not match the number of {IMAGE_PLACEHOLDER} tokens in {messages}."

View on GitHub (pinned to f28afaf635)

Solutions

  1. Load the complete official audio-capable checkpoint so its feature extractor config ships along.
  2. Upgrade transformers/LlamaFactory to versions supporting the audio model's processor.
  3. Check AutoProcessor.from_pretrained(path).feature_extractor is not None before launching training.
  4. Pass trust_remote_code: true if the checkpoint uses a custom processor class.

Example fix

# before
model_name_or_path: /models/qwen2-text-only
template: qwen2audio

# after
model_name_or_path: Qwen/Qwen2-Audio-7B-Instruct
template: qwen2audio
trust_remote_code: true
Defensive patterns

Strategy: validation

Validate before calling

from transformers import AutoProcessor

def has_feature_extractor(model_path: str) -> bool:
    try:
        p = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)
        return getattr(p, "feature_extractor", None) is not None or getattr(p, "audio_processor", None) is not None
    except Exception:
        return False

Prevention

When it happens

Trigger: Audio-capable template paired with a checkpoint whose processor lacks feature_extractor/audio_processor attributes; wrong processor class auto-resolved due to missing or outdated processor_config.json; transformers too old for the audio model.

Common situations: Text checkpoints used with audio templates; re-uploads missing feature_extractor_config.json; custom processor classes behind trust_remote_code whose installed version differs.

Related errors


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