Skip to content

vllm.model_executor.models.whisper

Classes:

WhisperAudioInputs

Bases: TensorSchema

Dimensions: - b: Batch size - nmb: Number of mel bins - t: Time frames (M)

WhisperEncoderAttention

Bases: MMEncoderAttention

Multi-headed attention for Whisper encoder with 2D tensor support.

Methods:

  • forward –

    Input shape: batch_size x seq_len x hidden_size

forward(query, key, value, cu_seqlens=None, max_seqlen=None, sequence_lengths=None)

Input shape: batch_size x seq_len x hidden_size or seq_len x hidden_size

WhisperForConditionalGeneration

Bases: Module, SupportsTranscription, SupportsMultiModal, SupportsLoRA

Methods:

get_language_detection_prompt(audio, stt_config) classmethod

Return a prompt that elicits a single language token from Whisper.

Feed only <|startoftranscript|> as the decoder input so the model predicts the most likely language token (e.g. <|de|>).

get_language_token_ids(tokenizer) classmethod

Return token IDs for all supported language tokens.

Used with SamplingParams.allowed_token_ids to constrain language detection to only produce valid language tokens.

parse_language_detection_output(token_ids, tokenizer) classmethod

Parse the language token predicted by Whisper.

Decodes the first token ID and extracts the language code from the <|xx|> format. Expects a valid language token from constrained generation.

WhisperProcessingInfo

Bases: BaseProcessingInfo

Methods:

get_target_channels()

Return target audio channels for Whisper models (mono).

_create_fake_bias_for_k_proj(weights, fake_bias_key_name, out_features=None)

Create full zeros bias for k_proj weight in self-attn and x-attn layers. So that the bias for k_proj in qkv_proj or kv_proj can be initialized with zeros.

If the checkpoint already provides a real .bias entry for the given weight, it is forwarded as-is and no fake bias is injected for that layer.