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–Build dummy inputs for BAGEL model profiling.
-
BagelForConditionalGeneration–BAGEL: A unified multimodal model for image understanding and generation.
-
BagelImagePixelInputs–Dimensions:
-
BagelMultiModalProcessor–Multimodal processor for BAGEL model.
-
BagelProcessingInfo–Processing information for BAGEL model.
-
BagelVisionMLP–MLP connector for vision features.
-
PositionEmbedding–2D position embedding for vision tokens using sin-cos embeddings.
BagelDummyInputsBuilder
¶
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:
-
embed_multimodal–Get multimodal embeddings from input.
-
forward–Run forward pass for BAGEL.
-
load_weights–Load weights from checkpoint.
_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
¶
PositionEmbedding
¶
Bases: Module
2D position embedding for vision tokens using sin-cos embeddings.
Methods:
-
forward–Args:
_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.