Skip to content

vllm.model_executor.models.gemma3n_mm

Classes:

Functions:

Gemma3nAudioInputs

Bases: TensorSchema

Dimensions: - bn: Batch size * number of audios - s: seq_length - f: num_features

Gemma3nForConditionalGeneration

Bases: Module, SupportsMultiModal, SupportsTranscription

Methods:

get_generation_prompt(stt_params) classmethod

Gemma3n supports "free-form" transcription. We fix its prompt here to standardize transcriptions/translations requests.

get_mm_mapping()

Get the module prefix in multimodal models

Gemma3nImagePixelInputs

Bases: TensorSchema

Dimensions: - bn: Batch size * number of images - c: Number of channels (3) - h: Height of each patch - w: Width of each patch

Gemma3nMultiModalProcessor

Bases: BaseMultiModalProcessor[Gemma3nProcessingInfo]

_get_num_audio_frames_alone(num_samples)

Get the number of mel frames that the feature extractor produces for a single audio clip of the given length, independent of batch padding.

Gemma3nMultimodalEmbedder

Bases: Module

Embeds token ids or soft tokens for multimodal content into language model space.

Methods:

  • forward –

    Embeds token ids or soft tokens for multimodal content into language model space.

forward(input_ids=None, inputs_embeds=None)

Embeds token ids or soft tokens for multimodal content into language model space.

Parameters:

  • input_ids

    (LongTensor | None, default: None ) –

    A torch.LongTensor containing the token ids to embed. Values should be in the range [vocab_offset, vocab_offset + vocab_size).

  • inputs_embeds

    (Tensor | None, default: None ) –

    A torch.Tensor containing the soft tokens to embed.

Returns:

  • Tensor –

    A torch.Tensor of embeddings with shape [batch_size, seq_len, self.config.text_config.hidden_size].

Gemma3nProcessingInfo

Bases: BaseProcessingInfo

Methods:

get_audio_repl(*, processor)

Get the replacement metadata for audio tokens.

For Gemma3n, this should return the full_audio_sequence which includes BOA token, repeated audio tokens, and EOA token.

get_image_repl(*, image_width, image_height, processor)

Get the replacement metadata for image tokens.

For Gemma3n, this should return the full_image_sequence which includes BOI token, repeated image tokens, and EOI token.

batch_audio_features(input_features, input_features_mask)

Return mel features and their validity mask as batched tensors.

Audio features are unpadded per item so that a multimodal cache entry does not depend on the batch it was first processed in. MultiModalFieldConfig.batched stacks items only when their shapes agree, so a batch of clips with differing durations reaches the model as a list and must be re-padded here.

Padded frames are zero-filled and marked invalid. Audio towers consume the mask, and callers keep only masked-in positions, so padding never reaches the language model.

Gemma4 shares this helper: its audio path has the same unpad/re-pad contract and the same fields.

Parameters:

  • input_features

    (Tensor | list[Tensor]) –

    (bn, s, f) tensor, or a list of (s_i, f) tensors when clip durations differ.

  • input_features_mask

    (Tensor | list[Tensor]) –

    Matching (bn, s) tensor, or list of (s_i,) tensors. True marks a valid frame.

Returns: