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>"
)
Problem
The auto-generated inference notebook/code on the model page is incorrect.
It uses:
This fails with:
because Whisper is a speech-to-text model and must be loaded with WhisperForConditionalGeneration or AutoModelForSpeechSeq2Seq.
Correct code