Skip to content

Whisper models are incorrectly mapped to Seq2SeqLM #1903

@irudachirath

Description

@irudachirath

Problem

The auto-generated inference notebook/code on the model page is incorrect.

It uses:

from transformers import AutoModelForSeq2SeqLM

base_model = AutoModelForSeq2SeqLM.from_pretrained("openai/whisper-small")

This fails with:

ValueError: Unrecognized configuration class WhisperConfig for AutoModelForSeq2SeqLM

because Whisper is a speech-to-text model and must be loaded with WhisperForConditionalGeneration or AutoModelForSpeechSeq2Seq.

Correct code

from transformers import WhisperForConditionalGeneration
from peft import PeftModel

base_model = WhisperForConditionalGeneration.from_pretrained(
    "openai/whisper-small"
)

model = PeftModel.from_pretrained(
    base_model,
    "<your-peft-adapter-in-huggingface>"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions