Skip to content

vllm.model_executor.models.bagel

Inference-only BAGEL model compatible with HuggingFace weights.

BAGEL is a unified multimodal model for image understanding and generation. For vLLM, we focus on the image understanding (vision-to-text) capabilities.

Classes:

BagelDummyInputsBuilder

Bases: BaseDummyInputsBuilder[BagelProcessingInfo]

Build dummy inputs for BAGEL model profiling.

BagelForConditionalGeneration

Bases: Module, SupportsMultiModal, SupportsLoRA, SupportsPP

BAGEL: A unified multimodal model for image understanding and generation.

For vLLM, we focus on the image understanding (vision-to-text) capabilities. The image generation part is not supported in vLLM.

Methods:

_process_image_input(image_input)

Process image inputs through vision encoder and connector.

embed_multimodal(**kwargs)

Get multimodal embeddings from input.

forward(input_ids, positions, intermediate_tensors=None, inputs_embeds=None, **kwargs)

Run forward pass for BAGEL.

Parameters:

  • input_ids

    (Tensor | None) –

    Flattened (concatenated) input_ids corresponding to a batch.

  • positions

    (Tensor) –

    Flattened (concatenated) position ids corresponding to a batch.

  • intermediate_tensors

    (IntermediateTensors | None, default: None ) –

    Intermediate tensors from prior forward pass.

  • inputs_embeds

    (Tensor | None, default: None ) –

    Optional tensor of input embeddings.

  • **kwargs

    (object, default: {} ) –

    Multimodal inputs for this batch, forwarded to the multimodal embedding path.

load_weights(weights)

Load weights from checkpoint.

BagelImagePixelInputs

Bases: TensorSchema

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

BagelMultiModalProcessor

Bases: BaseMultiModalProcessor[BagelProcessingInfo]

Multimodal processor for BAGEL model.

_get_prompt_updates(mm_items, hf_processor_mm_kwargs, out_mm_kwargs)

Replace image placeholders with the correct number of tokens.

BagelProcessingInfo

Bases: BaseProcessingInfo

Processing information for BAGEL model.

BagelVisionMLP

Bases: Module

MLP connector for vision features.

PositionEmbedding

Bases: Module

2D position embedding for vision tokens using sin-cos embeddings.

Methods:

_get_1d_sincos_pos_embed_from_grid(embed_dim, pos) staticmethod

Generate 1D sin-cos position embeddings.

_get_2d_sincos_pos_embed(embed_dim, grid_size) staticmethod

Generate 2D sin-cos position embeddings.

_get_2d_sincos_pos_embed_from_grid(embed_dim, grid) staticmethod

Generate 2D sin-cos position embeddings from grid.

forward(position_ids)

Parameters:

  • position_ids

    (Tensor) –

    Flattened position IDs, shape (N,) where each ID corresponds to a position in the flattened grid

Returns: Position embeddings of shape (N, hidden_size)