vllm.model_executor.models.granite_speech
¶
Inference-only IBM Granite speech model.
Classes:
-
GraniteSpeechAudioInputs–Audio input features for Granite Speech model.
-
GraniteSpeechCTCEncoder–CTC Encoder comprising conformer blocks and additional linear layers.
-
GraniteSpeechConformerAttention–Attention for conformer blocks using Shaw's relative positional
-
GraniteSpeechConformerBlock–Conformer block, consisting largely of linear layers,
-
GraniteSpeechConformerConvModule–Conformer conv module consisting of several 1D/depthwise 1D
-
GraniteSpeechConformerDepthWiseConv1d–Wrapper for padded 1D pointwise convolution.
-
GraniteSpeechConformerFeedForward–Feedforward module for conformer encoder blocks.
-
GraniteSpeechForConditionalGeneration–
GraniteSpeechAudioInputs
¶
Bases: TensorSchema
Audio input features for Granite Speech model.
Dimensions
- b: Batch size
- fi: Number of input features from the Mel spectrogram.
- fo: Number of output features, i.e. the embedding size.
- 160: Fixed feature dimension for Mel spectrogram features
Attributes:
-
audio_embed_sizes(Annotated[list[int], TensorShape(b)]) –List of audio embedding sizes for each item in batch.
-
input_features(Annotated[Tensor, TensorShape(b, fi, 160)]) –Audio input features.
-
input_features_mask(Annotated[Tensor, TensorShape(b, fo)]) –Mask for variable length audio features.
GraniteSpeechCTCEncoder
¶
GraniteSpeechConformerAttention
¶
GraniteSpeechConformerBlock
¶
Bases: Module
Conformer block, consisting largely of linear layers, attention, and convolutional layers.
GraniteSpeechConformerConvModule
¶
GraniteSpeechForConditionalGeneration
¶
Bases: Module, SupportsMultiModal, SupportsPP, SupportsLoRA, SupportsTranscription
Methods:
-
embed_multimodal–Compute the audio embeddings if audio inputs are present.
-
get_generation_prompt–Get the generation prompt to be used for transcription requests.
-
get_mm_mapping–Get the module prefix in multimodal models.
-
get_num_audio_tokens–Get the number of audio tokens for an audio duration in sec.
-
get_speech_to_text_config–Get the stt config for this model.
_build_input_features_mask(audio_embed_sizes)
¶
Calculate the input features mask, which will generally be used to mask the padded features for all entries in the batch except for those with the most audio features.
Parameters:
Returns:
_pad_and_stack_input_features(input_features)
¶
Given a list of input features of varying length, pad them to the same length and stack them into a torch.Tensor.
NOTE: Usually, padding is done in the input processor/feature extractor and zero padded prior to the computation of the Mel features; the resulting values are only constant within a batch and generally nonzero (i.e., slightly negative nums); we should validate that this is okay since we don't use a feature attention mask, but the more important thing is that we apply the input_features_mask with variable len batches.
Parameters:
Returns:
_process_audio_input(audio_input)
¶
Compute the audio features to be merged into the LLM embeddings.
Parameters:
-
(audio_input¶GraniteSpeechAudioInputs) –GraniteSpeechAudioInputs Audio inputs object containing Mel features, an input features mask, and the (flattened) number of audio tokens per instance.
Returns:
embed_multimodal(**kwargs)
¶
Compute the audio embeddings if audio inputs are present.
get_generation_prompt(stt_params)
classmethod
¶
Get the generation prompt to be used for transcription requests.
get_mm_mapping()
¶
Get the module prefix in multimodal models.
get_num_audio_tokens(audio_duration_s, stt_config, model_config)
classmethod
¶
Get the number of audio tokens for an audio duration in sec.
get_speech_to_text_config(model_config, task_type)
classmethod
¶
Get the stt config for this model.